I wrote a regular expression in hope that I will be able to replace every match (that is just one char) to upper case char. I am using EditPad Pro (however I am willing to use any other tool that would allow me to do this, as long as it is free to try, since I only need to do this once).
Background: I have a very long text file used by a case sensitive application, and some words start with lower case instead of upper case char, thus crashing the application. This would take very long to do by hand, and it would be quite complicated to do without regular expressions because the occurrence of the (evil) lower case char is very specific.
I have written the select regular expression and now I can use it with a backreference ($1 works just fine) however I can't make it replace with upper case char. I thought something like \u$1 would work, however it doesn't in EditPad Pro.
If no free tool allows me to do this, I guess the alternative would be to just do it in C# however I am in a bit of a hurry and not near a compiler, so I'd have to download the express edition first, so ... It would be preferable to find a tool that supports such a feature!
Thank you!
This can be done easily using regular expressions. In a substitute command, place \U or \L before backreferences for the desired output. Everything after \U , stopping at \E or \e , is converted to uppercase. Similarly, everything after \L , stopping at \E or \e , is converted to lowercase.
RegEx makes replace ing strings in JavaScript more effective, powerful, and fun. You're not only restricted to exact characters but patterns and multiple replacements at once.
Java String toUpperCase() Method The toUpperCase() method converts a string to upper case letters. Note: The toLowerCase() method converts a string to lower case letters.
[] denotes a character class. () denotes a capturing group. (a-z0-9) -- Explicit capture of a-z0-9 . No ranges.
TextPad will allow you to perform this operation.
example:
test this sentence
Find what: \([^ ]*\) \(.*\)
Replace with: \U\1\E \2
the \U
will cause all following chars to be upper
the \E
will turn off the \U
the result will be:
TEST this sentence
I know this thread is about EditPad Pro, but I came here because I had the same need with a javascript regexp.
For the people who are here needing the same tip, you can use a function or lambda as the replace argument.
I use the function below to convert css names with -
to the javascript equivalent, for example, "border-top"
will be transformed into "borderTop"
:
s = s.replace(/\-[a-z]/g, x => x[1].toUpperCase());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With