javascript - Regex calling backreferences from all group interations -


i'm catching international numbers , running regex replace characters people put between numbers.

i'm using below regex:

[+]([0-9]{1,3})(([\s\-\.\(\)]*)([0-9]*)([\s\-\.\(\)]*)){1,3} 

it works great when use repeated group, catches last iteration. when use regex101 site debug regular expression, see:

a repeated capturing group capture last iteration. put capturing group around repeated group capture iterations

i want take advice i'm not sure how can put capturing group around repeated group. see: https://regex101.com/r/pt3ck9/1

as stated in comments, simples way clean phone numbers define list of unwanted characters, , replace them spaces:

'+94 (666) 999-5555'.replace(/[ .()-]+/g, ' '); // +94 666 999 5555 '+42 555.123.4567'.replace(/[ .()-]+/g, ' ');   // +42 555 123 4567 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -