Search code examples
phpphp-5.3

How do I split this word using PHP?


There are many words like this.....

mathewthomas256
alexcannon5623
kohlanjame9568
nancycherikom257

how do I remove numbers from above names using PHP? there are around 200k names like this


Solution

  • preg_replace("/\d+$/gm", "", input)
    

    The regex is "all digits (\d+) at the end of the line ($)". This works in a line-based manner because of the m modifier and globally over all lines because of the g modifier.