Questions tagged [string-manipulation]

115 questions
49
votes
6 answers

How to extract part of a string in Windows batch file?

Suppose I have a value such as "Abc_123" that's stored in a variable in a batch (cmd) file. I want to end up with a variable that contains only "123". Is there any built-in way to do this? I'm not terribly picky about the method, or performance,…
Ken
  • 635
22
votes
4 answers

Any Excel function that will reverse a string?

Are there any built-in Excel functions that will reverse a string?
20
votes
7 answers

How to split a string with quotes (like command arguments) in bash?

I have a string like this: "aString that may haveSpaces IN IT" bar foo "bamboo" "bam boo" I want to be able to split it like this: aString that may haveSpaces IN IT bar foo bamboo bam boo How do I do that? (preferrably using a one-liner)
foxneSs
  • 303
18
votes
4 answers

Bash 4.3 Substring Negative Length on OS X

Bash 4.2 added support for negative substring lengths: http://tldp.org/LDP/abs/html/abs-guide.html#SUBSTREXTR01 Example 37-12. Negative parameter in string-extraction construct When the "length" parameter is negative, it serves as an…
14
votes
3 answers

How to remove extension from pathname passed as {} in `find -exec`?

Given the situation that audio needs to be extracted from video files residing in subdirectories, how would one go about properly naming the resulting files? The following one-liner works, but retains the old file extension. find -name "*.mp4" -exec…
Daktari
  • 173
12
votes
3 answers

Replace every nth instance of a character with a new line in Notepad++

I have a pipe delimited string of NAME|VALUE pairs looking something like this.. Name1|Value1|Name2|Value2|Name3|Value3 What I want to do is to replace every second instance of | with a new line so that I have something like…
12
votes
9 answers

How to create a random string of random length from the alphabet?

I want to create a random string with random length from the alphabet in Excel. For example, "jlskdjf", "kjlk", "kljsodif", etc. How can I do that?
8
votes
1 answer

In convert case, what is the difference between blend and normal version?

In notepad++, if you go to Edit > Convert Case to, you have entries like: Proper Case Proper Case (blend) Sentence case Sentence case (blend) What is the difference between blend and "normal" version ?
bhorys
  • 83
6
votes
4 answers

awk match whole word

I want to use awk to match whole words from text file. Including words bounded by non alphanumeric characters. For example - string to search for - ABC Source file - HHHABCCCCH HHH ABC HH(ABC)ASDAASD HH,ABC-ASASDASD Result - HHH…
bryan
  • 8,528
  • 4
  • 30
  • 42
6
votes
1 answer

Replace every 6th pipe in powershell

I realize I'm asking a similar question that was already asked and answered but I was not able to extrapolate the answer I needed since the regex and regex engine is different enough. I have hardware asset management logs which are pipe delimited…
Tensore
  • 73
5
votes
3 answers

How to find the common paths from a list of paths/files

Prelude: Given a sorted input of a list of paths/files, how to find their common paths? Translating into tech term, if feeding the sorted input from stdin, how to pick the shortest proper prefix from the stdin? Here the "prefix" has the normal…
xpt
  • 9,385
  • 44
  • 120
  • 178
5
votes
2 answers

How can I do string manipulation in fish shell

How can I do bash style string manipulations in Fish shell? Specifically, in bash read branch < ".git/HEAD" branch=${branch#ref: refs/heads/} will put the branch name in $branch variable. How can I do the same in fish shell? I glanced over…
blackwing
  • 631
5
votes
1 answer

How do I append dynamic number of spaces at the end of a string in a batch file

I want to output information to a log file as such 01/08/2013 14:30 - Dynamic-Machine-Name - Message starts 02/08/2013 07:12 - DynamicMachineName - Log entry 02/08/2013 07:14 - Dynamic-PC-Name - Information here 02/08/2013 08:01 -…
5
votes
1 answer

Reverse Name order in Notepad++

I have a load of names in a file in the format Lastname, Firstname: Williams, Hywel Williams, Mark  Williams, Roger Williams, Stephen ... Is there a simple way of reversing them in Notepad++, to get each line reversed into Firstname…
fredley
  • 3,457
4
votes
2 answers

Extract a Whole Word From String Containing a Specific Letter or Character

I would like to extract only the word from a cell that contains a specific character ("=") within the text. A2: Dolly made me a homemade=cake and some muffins A3: we had cheese=cake for dinner A4: Everyone loves how the bakery makes some…
1
2 3 4 5 6 7 8