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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -