Regex: How can I capitalize the first letter that immediately follows a number EXCEPT for 1st, 2nd, 3rd, etc -


so i'm editing regex code mass mp3 rename tool , hoping there's code capitalize every letter follows number. instance, 2nite > 2nite , 221b > 221b keep 11th > 11th , 2nd > 2nd unchanged.

you don't language you're using. here's you'd in perl

s/(?<=\d)(?!(?:st|nd|rd|th)\b)([[:lower:]])/\u$1/g 

where

  • (?<=\d) behind digit
  • (?!(?:st|nd|rd|th)\b) ahead not "st" or "nd" or ...
    • \b word boundary marker, 1st stays intact 1stop becomes 1stop
  • ([[:lower:]]) lower case letter (captured)
  • \u$1 in replacement side, upper case first letter of text in first capturing parentheses

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -