Page 1 of 1

Match and replace 2 characters? 1 set and 1 flexible?

Posted: Tue Jul 26, 2011 12:52 pm
by wires
Is it possible to match a specific character and any single character then replace both characters with the uppercase version of the single character? Here is an example:
starting string: -axx-bxxx-9xxx-c
resulting string: AxxBxxx9xxxC

I have a files with auto-generated contents that needs to be converted in the way described above and right now I'm stuck making the conversions by hand. It would help me out a great deal to be able to make all the replacements at once. Thank you.

Posted: Tue Jul 26, 2011 1:30 pm
by ben_josephs
Use "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Search | Replace... (<F8>):
Find what: -(.)
Replace with: \u\1

[X] Regular expression

Replace All

Question clairification

Posted: Tue Jul 26, 2011 4:32 pm
by wires
Thank you! Your answer worked like a charm. Unfortunately I didn't phrase my question correctly. The files I need to perform the text replacements on are XML and the text that needs to be replaced are just in name="" tags so a better example is:
<bind-xml name="interchange-control-trailer" node="element" reference="false"/>

and the outcome needs to be:
<bind-xml name="interchangeControlTrailer" node="element" reference="false"/>

I did some research on Posix regular expressions and the best that I was able to come up with is:
find what: name="[a-zA-Z0-9]-(.)"
Replace with: name="\u\1"

But that doesn't work. Can you help me once more?



ben_josephs wrote:Use "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Search | Replace... (<F8>):
Find what: -(.)
Replace with: \u\1

[X] Regular expression

Replace All

Posted: Tue Jul 26, 2011 9:11 pm
by ben_josephs
Find what: name="([a-z0-9-]+)-([a-z0-9]+)"
Replace with: name="\1\u\2"

[X] Regular expression

Replace All -- do this repeatedly until it beeps

Question answered!

Posted: Tue Jul 26, 2011 10:06 pm
by wires
It worked like a charm. That saves me a ton of time. You are awesome. Thank you very much.
ben_josephs wrote:
Find what: name="([a-z0-9-]+)-([a-z0-9]+)"
Replace with: name="\1\u\2"

[X] Regular expression

Replace All -- do this repeatedly until it beeps