This replaces the value in parameters in a url. NOT in html, as I now see that is what you mean. Oh well.
- Find what:
(\?|\&)([a-z_]+=)([a-z])([^&]+)
- Replace (all) with:
$1$2\u$3$4
Free spaced:
(\?|\&)
Capture group 1: Either the literal question mark or ampersand.
([a-z_]+=)
Capture group 2: One or more of any lowercase letter or underscore, followed by the equals sign.
([a-z])
Capture group 3: The first letter in the value of the url parameter. Note this does not even notice parameters whose values don't start with a letter.
([^&]+)
Capture group four: Every other character in the value. Or more specifically, one or more of any character as long as it's not an ampersand. This is a negative character class.
The \u in the replace-with is an option in TextWrangler (and in TextPad, which is what I use...so TextWrangler might also use the Boost regex engine) replacement that uppercases the immediately-following character. I'm not sure if this would work if capture groups 3 and 4 were merged.
Try it (although it doesn't have the \u
option.)
Please consider bookmarking the Stack Overflow Regular Expressions FAQ for future reference. There's a lot of helpful information in it, including a list of online regex testers (in the bottom section), so you can try things out yourself. All the links in this answer come from the FAQ.