Regex pattern question

Hey everyone,

I have a text as:

" \r\nTemp-No;: 1234567\r\n03.01.2021\r\n123456\r\nThanks "

from this text I need to get 3 variables which are:
1234567 as number variable
03.01.2021 as date variable
123456 as ticketno variable

I believe there should be 3 different expression for each variable.

Any help?

1 Like

Hello @jntrk,

to extract 03.01.2021: \d{1,2}.\d{1,2}.\d{4}
to extract 123456 : \d+

You can extract all information with one regex.

And then access every value,by calling a different group e.g. 1,2,3

I get empty string. I did like this.

assigned val= System.Text.RegularExpressions.RegEx.Match(texttt, “(\d{7})\r\n(\d{1,2}.\d{1,2}.\d{4})\r\n(\d{6})”).Value

when I execute it I get empty string “”

You need to specify the group (enclosed by parenthesis in the regex patern).

For the first value: System.Text.RegularExpressions.RegEx.Match(texttt, “(\d{7})\r\n(\d{1,2}.\d{1,2}.\d{4})\r\n(\d{6})”).Groups(1).Tostring

For the second value: System.Text.RegularExpressions.RegEx.Match(texttt, “(\d{7})\r\n(\d{1,2}.\d{1,2}.\d{4})\r\n(\d{6})”).Groups(2).Tostring


1 Like

Thank you

1 Like

i try it but its return empty value could you please example of workflow

can you tells us what is the input string you are using and which information you want to extract?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.