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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -