Hello,
I would like to change several strings at the same time I don´t figure it out. I have, for example these two different strings in the same text file:
dlc1.2a.$07
dlc2.2a.$07
The goal is to replace them with the same name except the the first "." character in only one step using regular expressions, the result should be:
dlc12a.$07
dlc22a.$07
Thank you very much.
replace with regular expressions
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
-
- Posts: 5
- Joined: Tue Jun 12, 2012 5:34 pm
- Contact:
Is This Replacement Possible?
I'm new at figuring out replacement expressions so any help getting
me going with this would be most appreciated.
I've tried a bunch of things in the help files, but there isn't much on
how to combine regular expressions with segments of existing code
to identify where to start and stop the regex, so I keep getting the
"not found" alert when I run the search and replace. What I want to do is:
Search For: ST2('SomeText-01a')
And replace it with: ST2(this.id)
EXAMPLE OF MY STUPIDITY: I tried to find ST2('[:alpha:]-01a') to remove "any letters" ... but I obviously don't know what I'm doing ... help!
I have over 300 replacements to make and each example of "SomeText" represents a different text string.
I've gotten to the point now where I need to
Search For: ST2(this.id)SomeText-01a')"
And need to replace the part: SomeText-01a') with nothing ( remove it ).
me going with this would be most appreciated.
I've tried a bunch of things in the help files, but there isn't much on
how to combine regular expressions with segments of existing code
to identify where to start and stop the regex, so I keep getting the
"not found" alert when I run the search and replace. What I want to do is:
Search For: ST2('SomeText-01a')
And replace it with: ST2(this.id)
EXAMPLE OF MY STUPIDITY: I tried to find ST2('[:alpha:]-01a') to remove "any letters" ... but I obviously don't know what I'm doing ... help!
I have over 300 replacements to make and each example of "SomeText" represents a different text string.
I've gotten to the point now where I need to
Search For: ST2(this.id)SomeText-01a')"
And need to replace the part: SomeText-01a') with nothing ( remove it ).
-
- Posts: 5
- Joined: Tue Jun 12, 2012 5:34 pm
- Contact:
Most Excellent!bbadmin wrote:To tackle your original problem:
Search For: ST2('SomeText-01a')
And replace it with: ST2(this.id)
The regular expression needs to eat everything between the literal brackets:
ST2\([^)]+\)
so everything that was matched can be replaced with:
ST2(this.id)
358 Big Thank Yous in about .8 secs
I'll study this and learn from it too.