REGEX – Remove Letters from string

Removing letters from a string using Regular Expressions.

Very simple. but brain bending – All I wanted to do was remove a prefix from a string.

The prefix was always letters, and I only wanted the numerical suffix returned, so though, preg_replace was my best bet.

echo preg_replace("/[a-zA-Z]*/", '', '12345MystrING67890');

This returns :



Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.