Jump to content
UBot Underground

Javascript and Regex


Recommended Posts

var raw = '{1}';
var matches = raw.match(/\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})/g);
if ( matches != null) {
alert(matches[0]);
}

 

I'm trying to match a phone number in many formats. I've worked very hard to figure that regex out and tested it with different sandboxes

 

http://gskinner.com/RegExr/

 

http://www.pagecolumn.com/tool/regtest.htm

 

Ubot throws an error that doesn't give much explanation, just the text from my code (shown above). Anyone able to shed some light on this?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...