Amandeep Singh Amandeep Singh - 1 year ago 66
PHP Question

How to match digits between strings not between numbers

Is it possible to write a regular expression that matches with digits that does not have integer on left or right side? If we have these strings:


It should match the four first, but not the last one.

Answer Source

This regex patterns will match text that has the 20 somewhere in the middle and of which no other number is touching the 20. This could occur anywhere in the text, therefore matching DM11 20-B but not DM1120-B.


Or a little more condensed:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download