Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript get phone number from string

const string = 'test1 +91 9443134651 test2 +1 671-765-0091';
let phone_numbers = [];
const regexp = new RegExp("+?(?d*)? ?(?d+)?d*([s./-]?d{2,})+","g");

let match;
while ((match = regexp.exec(string)) !== null) {
  console.log(`${match[0]}`);
}
// output:
//+91 9443134651
//+1 671-765-0091
//+33442207724
Source by www.w3tweaks.com #
 
PREVIOUS NEXT
Tagged: #javascript #phone #number #string
ADD COMMENT
Topic
Name
1+2 =