vivekporwal04 vivekporwal04 - 1 year ago 161
PHP Question

translate Ruby regex to php/perl regex

I have made this regex, which works fine in Ruby:


It's for extracting phone numbers from text document but now I'm using the same expression in PHP, using
. Now the same expression gives me an empty array.

I don't understand why this is happening

What do I need to change about this expression to make it work in PHP?

Answer Source

You have a strange error in your Regexp. I think it's partially luck it's working on Rubular:

   ^         ^

Why are those brackets there two times?

See here for a working version where I just removed those. Works fine with PHP now:

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