Questions tagged [string-manipulation]

107 questions
40
votes
5 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
  • 545
  • 1
  • 5
  • 8
22
votes
4 answers

Any Excel function that will reverse a string?

Are there any built-in Excel functions that will reverse a string?
mindless.panda
  • 7,142
  • 10
  • 46
  • 65
16
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
  • 263
  • 1
  • 2
  • 6
15
votes
3 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…
Brent Faust
  • 428
  • 1
  • 5
  • 11
12
votes
7 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?
Jenny Hoang
  • 145
  • 1
  • 1
  • 6
10
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…
Pieter van Niekerk
  • 683
  • 4
  • 11
  • 24
6
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,347
  • 10
  • 30
  • 41
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
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
  • 551
  • 1
  • 5
  • 14
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 -…
Ghandi Manning
  • 225
  • 1
  • 3
  • 9
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…
user498469
  • 41
  • 1
  • 2
4
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
  • 7,031
  • 28
  • 86
  • 129
4
votes
2 answers

Bash prefix string with tilde to expand to home directory

I can't figure out how to prefix a string (e.g. "user1") with a tilde (~) to produce ~user1 and have that expand to user1's home directory. Here is what I have now: USER="user1" ls ~${USER} ls: cannot access ~user1: No such file or directory ~user1…
bernie
  • 280
  • 1
  • 3
  • 10
4
votes
2 answers

VI make every first letter that comes after a underscore uppercase

Found this site: http://unix.t-a-y-l-o-r.com/VMswitch.html And it works for the first character but my lines are line this this_is_a_string And I would like this This_Is_A_String Any thoughts? VI Command would be nice but any other simple…
Phill Pafford
  • 245
  • 2
  • 3
  • 12
4
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
  • 43
  • 3
1
2 3 4 5 6 7 8