UBot Marketer 7 Posted June 15, 2014 Report Share Posted June 15, 2014 (edited) Hi , I'm stuck in this I need to validate mobile number : The number may start with +9665 or 009665 or 05 OR 9665 The next digit after the 5 can be from 0 to 9 Then after that exact 7 digit. What i did so far by this site http://rubular.com/r/dodmKZnYLa ^(?:\+?966)[5]\d{8}$ I couldn't do the 009665 / 05 Any suggestions appreciated I forget the 9665 i add it Edited June 16, 2014 by UBot Marketer Quote Link to post Share on other sites
UBot Marketer 7 Posted June 15, 2014 Author Report Share Posted June 15, 2014 still couldn't do the last one (start with 05 ) http://rubular.com/r/ep5WGQA2Za [0]*(?:\+?966)[5]\d{8} Quote Link to post Share on other sites
UBot Marketer 7 Posted June 15, 2014 Author Report Share Posted June 15, 2014 IS this the beast way ? http://rubular.com/r/CkfC7cwBQm ^(009665|9665|\+9665|05)(5|0|3|6|4|9|1)([0-9]{7})$ Quote Link to post Share on other sites
LazyBotter 188 Posted June 15, 2014 Report Share Posted June 15, 2014 This any good?^(?:\+?.*)[5]\d{8}$ http://rubular.com/r/eJI6kl4pw1 Quote Link to post Share on other sites
UBot Marketer 7 Posted June 16, 2014 Author Report Share Posted June 16, 2014 This any good? ^(?:\+?.*)[5]\d{8}$ http://rubular.com/r/eJI6kl4pw1 Thanks for your try Almost BUT it scraped the numbers start with 66 and 55 ( and i do not want them ) Thanks again , i think i will go with my tallllllllll string ^(009665|9665|\+9665|05)(5|0|3|6|4|9|1)([0-9]{7})$ Quote Link to post Share on other sites
Team_LX 3 Posted June 16, 2014 Report Share Posted June 16, 2014 give me examples of full numbers your trying to get ? also i worked on this some what adn i think the easiest thing would be to reg the items in diff var then bring them togther in a new list ? Quote Link to post Share on other sites
HelloInsomnia 1103 Posted June 16, 2014 Report Share Posted June 16, 2014 Hi Bakr, How about this? http://rubular.com/r/KmynLZ6iP2 Quote Link to post Share on other sites
UBot Marketer 7 Posted June 16, 2014 Author Report Share Posted June 16, 2014 give me examples of full numbers your trying to get ? also i worked on this some what adn i think the easiest thing would be to reg the items in diff var then bring them togther in a new list ? The numbers will be either +9665xxxxxxxx009665xxxxxxxx9665xxxxxxxx05xxxxxxxx The ( x ) is 8 digits Hi Bakr, How about this? http://rubular.com/r/KmynLZ6iP2 Thanks great , still did NOT get the one start with ( 9665 ) i know it is my mistake i forgot to add it to the post sorry Quote Link to post Share on other sites
HelloInsomnia 1103 Posted June 16, 2014 Report Share Posted June 16, 2014 Okay try this one: http://rubular.com/r/JZI9SjvmDL 1 Quote Link to post Share on other sites
UBot Marketer 7 Posted June 16, 2014 Author Report Share Posted June 16, 2014 Okay try this one: http://rubular.com/r/JZI9SjvmDL Excellent shorter than mine Quote Link to post Share on other sites
Marton 48 Posted June 16, 2014 Report Share Posted June 16, 2014 Okay try this one: http://rubular.com/r/JZI9SjvmDL A bit shorter, but basically the same: (\+?9665|009665|05)[0-9]{8,8} Quote Link to post Share on other sites
Marton 48 Posted June 16, 2014 Report Share Posted June 16, 2014 Ubot Marketer, keep in mind thought that the speed of a regular expression is not necessarily related to how short or long it is. I use this: http://regexhero.net/tester/ You can run benchmark tests for the different versions for a start. Quote Link to post Share on other sites
UBot Marketer 7 Posted June 16, 2014 Author Report Share Posted June 16, 2014 Ubot Marketer, keep in mind thought that the speed of a regular expression is not necessarily related to how short or long it is. I use this: http://regexhero.net/tester/ You can run benchmark tests for the different versions for a start. Thanks for the heads up , i am not expert in Regex and i thought it will be much accurate and faster if it as Symbols Quote Link to post Share on other sites
UBot Marketer 7 Posted June 16, 2014 Author Report Share Posted June 16, 2014 A bit shorter, but basically the same: (\+?9665|009665|05)[0-9]{8,8} Bit shorter AND Much better it work , mine didn't Thanks Nick 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.