Separating (+) from a Phone Number

Hello, I’m giving an example. A phone number starts with +90. How can I get this data in 2 separate ways. + and 90 will be separate.

I Need to Separate + from Phone Number

There are lots of ways to do this using string manipulation but probably the best is using a text parser and regular expression parser especially since there are many conditions such as

  • does the + and the code have a space or are next to each other
  • is the code next to other data or is there a space
  • what are the valid codes or are you validating on a number of any length.

If we assume a properly formatted international phone number this regex will work. The first two capture groups will extract the + and code and the last capture group will extract the phone number

(\+?)(\d{1,4}?[-.\s]?\(?\d{1,3}?\)?)[-.\s]?(\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9})

More details on REGEx101.

3 Likes

Thanks, Alex. It worked.

2 Likes

Um outro formato que descobri também de fazer que acredito que possa também ajudar!

{{replace(2.mappable_answers.Teléfono; “+”; tab)}}

aqui os dados que pego é direto do LinkedIn mas acredito que dê pra usar para outras situações