Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Change only one character to uppercase
- Samik R.
June 10, 2008, 4:03 am
rate this thread
I am trying to change only one character to uppercase, if the char is
after a hyphen (-). I can't think of a RE to do that. Right now, I am
splitting the word on -, and then using ucfirst() for the second word,
but I am curious if there is a better way.
For example, I have the word: "Springer-verlag". I want to have the word
Re: Change only one character to uppercase
You are able to make a regexp that matches a char after a hyphern,
The replace this match with "\U$1" and you're done. The escape
sequence '\U' uppercases the rest of the string (or until a
'\E'). Read about it in 'perldoc perlop' under the heading 'Quote and
- » FAQ 6.23 How do I match a regular expression that's in a variable?
- — Previous thread in » PERL Discussions