Regex matches error

Where does it go wrong?

This is what i try to get: Tel.: +123 2 321 222 11

I tried Matches activity too:

Hi @Ibra

I it works on the regex101.com, then try removing the marks for start of line and end of line ^ and $.

(\+(\d){3} (\d){1} (\d){3} (\d){3} (\d){2})

@Ibra In text.ToString() remove.ToString() and check

Nothing worked guys :frowning:

What i also tried was removing my For Each and placing a writeline only. I changed the pattern to “t” (a single character) and it did print out. Next i tried was only changing the pattern again (the “t”) to:

Bbut then i get this in my output panel:

System.Linq.Enumerable+d__97`1
[System.Text.RegularExpressions.Match]

EDIT: I debugged and the Matches activity was still empty when executed.

Correct regex would look like this, please try:
\+\d{3} \d{1} \d{3} \d{3} \d{2}

No need to use parentheses for every digit group unless you want to catch them separately :slight_smile:

Thank you! It worked!

But i have few questions before you leave my topic, please :slight_smile:

  1. What if i have 2 set of phone numbers: 1 is called “Tel.:” and the other is “Mob.:”.
  • How can i specific fetch the “Tel.:” instead of the other one that also contains the same amount of digits?

E.g.: Tel.: +123 2 123 123
Mob.: +321 3 321 321

  1. What does the start of that syntax mean “\ +” ?

Thank you.

  1. You can make your regex more specific:
    Tel\.: \+\d{3} \d{1} \d{3} \d{3} \d{2}

This answers your second question too - some characters are part of regex syntax and need to be escaped with a backwards slash \
As you can see above, I escaped the dot in Tel. and the plus sign +

It might be that the : character will also need an escape, but I’m not sure :slight_smile:

The general idea to regex is that you can type in your sentence as is or use a mix of stable parts and variable ones. In this case, you want to “hardcore” your "Tel.: ", but make the digits variable :slight_smile:

I tried this in regex101 but it also fetching “Tel.:” along with the digits. How do u remove it?

I see, my bad for misunderstanding that you want only the digits :slight_smile:
See below link for the solution:
regex101: build, test, and debug regex

Thank you!