BeerNut 25 Posted September 16, 2014 Report Share Posted September 16, 2014 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-89011-234-567-8901 x12341-234-567-8901 ext12341 (234) 567-89011.234.567.890112345678901 I take it that I can not just find RegEx's online and plug and play them into uBot? Quote Link to post Share on other sites
UBotDev 276 Posted September 16, 2014 Report Share Posted September 16, 2014 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. Quote Link to post Share on other sites
HelloInsomnia 1103 Posted September 16, 2014 Report Share Posted September 16, 2014 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. Quote Link to post Share on other sites
HelloInsomnia 1103 Posted September 16, 2014 Report Share Posted September 16, 2014 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} 1 Quote Link to post Share on other sites
UBotDev 276 Posted September 16, 2014 Report Share Posted September 16, 2014 Not just that but the fact that with Ubot you can't do {2} you have to do it like {2,2}Right, nice catch... Quote Link to post Share on other sites
giganut 109 Posted September 16, 2014 Report Share Posted September 16, 2014 Not just that but the fact that with Ubot you can't do {2} you have to do it like {2,2} Thank you sir! that was driving me crazy today. 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.