Skip to content
Advertisement

How to remove numbers from a string with RegEx

I have a string like this:

" 23 PM"

I would like to remove 23 so I’m left with PM or (with space truncated) just PM.

Any suggestions?

Needs to be in PHP

Advertisement

Answer

echo trim(str_replace(range(0,9),'',' 23 PM'));
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement