Extract Phone number from a text

Hello Guys,

is there a good regex fonction to extract phone number ( Tél) :

mmmmmmm Tél : 01 02 02 03 04 khhkjhkhhkh


hi @abdel
worked for me

mm__m5555:mmmm Tél : 01 02 02 03 04 khhkjii454_hkhhkh also?

i want to extract only the “Tél : 01 02 02 03 04”
i know that for US there is a regex Match formulat to extract the mobile phoe

to get the phone number only is: (?<=Tél : )(.*)(?= )

it does not work, for exemple for “a,klkjojjp2kjlkj- Tél : 01 02 03 04 05 avec jlkjlkjlkj” it gives 01 02 03 04 05 avec

1 Like

Hi if the input is stored in a variable named strinput
Then use this expression in ASSIGN activity like this
str_output = System.Text.RegularExpressions.Regex.Match(strinput.ToString,”(\d).+\s”).ToString.Trim

Cheers @abdel

1 Like

i had used it but for example for a string like: “a,klkjojjp2kjlkj- Tél : 01 02 03 04 05 avec jlkjlkjlkj” it did not work;

1 Like

Just a small correction
Use this expression instead with above mentioned one

Cheers @abdel

1 Like

kindly give me a solid text so that I can frame accordingly
Changing the input might not work with Regex often

So based on the examples given so far

(?<=Tél :)\s(\d).+(?=avec)

Cheers @abdel

@abdel Try with this Regex and let me know.

1 Like

(?<=Tél :).*\d+
Cheers @abdel

if i want to extract 01 49 30 3205 from

tél : 01 49 30 3205 fax : 01 41 21 15

(?<=tél :).*(?=fax)

but i prefere substring because fax is not Always present

will it be always Alphabets after number or numbers

yes because i’m extraction pdf information with OCR then i can expect any character after the tel number

1 Like

(?<=tél :).*(?=\s[a-zA-z])

1 Like

for all the possible ways you gave as inputs
here you with the expression
(?<=l :).[0-9\s0-9]*

in that case go for this one:
(?<=Tél :\s)([0-9 ]+)(?=\s)