I'm extracting the phone numbers that begin with 9 followed by other 9 digits from tweets using JavaScript.
Here's the regex pattern I am using:
var numberPattern = /^9[0-9]{9}/;
Here's the pattern matching phase:
var numberstring = JSON.stringify(data[i].text); if(numberPattern.test(data[i].text.toString()) == true){ var obj={ tweet : { status : data[i].text }, phone : numberstring.match(numberPattern) } //console.log(numberstring.match(numberPattern)); stringarray.push(obj); The problem is it is working for few numbers and not all. Also, I want to modify the regex to accept +91 prefix to numbers as well and(or) reject a starting 0 in numbers. I'm a beginner in regex, so help is needed. Thanks.
Example:
#Chennai O-ve blood for @arun_scribbles 's friend's father surgery in few days. Pl call 9445866298. 15May. via @arun_scribbles