Zend certified PHP/Magento developer

Regular Expression with Limitations

I’ve been working in a tool that doesn’t let me just use a Regex, so I have to use a RegexReplace to get rid of everything else. I’ve found a disgusting work around, but I think someone here can help me make an elegant solution.

So I’m trying to find a Regex that will identify everything except an exactly 10 digit number that starts with “200” “210” or “219” and replace it with “”. For example:

  • 12 abcd@gmail.com1234 2001234567 ab12
  • 210123 2101234567 xyz
  • 210123456789123456 2191234567 ab12
  • 2101234 xyz@gmail.com

Would return:

  • 2001234567
  • 2101234567
  • 2191234567
  • and the 4th row would be blank or null.