Jump to content
UBot Underground

Recommended Posts

I have been using simple regex with uBot for awhile now, but mostly ones I have made my self. Now I need a complex regex that will match phone numbers of various types.

 

I have found this RegEx below online. It works with EditPad, Rubular.com, and a few other regex checking programs I have. What it does not do is work with uBot Studio 4.0.

^(??:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$

It should match these phone numbers.

 

1-234-567-8901
1-234-567-8901 x1234
1-234-567-8901 ext1234
1 (234) 567-8901
1.234.567.8901
12345678901
 
I take it that I can not just find RegEx's online and plug and play them into uBot?
Link to post
Share on other sites

The problem is that regex you've found is used for input validation, that's why it has trailing ^ and ending $ and it doesn't work for your case.

 

If you remove those 2 characters the regex will work for scraping as you want.

Link to post
Share on other sites

Try this:

(??:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2,2})\s*(?:[.-]\s*)?([0-9]{4,4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?

Note: I removed the starting and ending line because you probably don't want that - but if you do the just add in the first character and last character again.

Link to post
Share on other sites

The problem is that regex you've found is used for input validation, that's why it has trailing ^ and ending $ and it doesn't work for your case.

 

If you remove those 2 characters the regex will work for scraping as you want.

 

Not just that but the fact that with Ubot you can't do {2} you have to do it like {2,2}

  • Like 1
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...