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.
Match and replace 2 characters? 1 set and 1 flexible?
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Question clairification
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?
<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:Search | Replace... (<F8>):Configure | Preferences | Editor
[X] Use POSIX regular expression syntaxFind what: -(.)
Replace with: \u\1
[X] Regular expression
Replace All
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Question answered!
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