Regex Pattern - Help

Can anyone help me to build a regex for the below text ?

Text :
sfedf
12344 12134 52636
ecrr
wc
12334 22\23 23345
24cr3
34ft4
\2334 22423 23\45dfjh
clsrhcueh
25424 34874 8973|

From the above text I need to extract the below strings.
12344 12134 52636
12334 22\23 23345
\2334 22423 23\45
25424 34874 8973|

HI @Manikandasamy

Checkout the expression

System.Text.RegularExpressions.Regex.Match(Youstr,"(?<=\D\n)\d.+|.*\\\d+(?=\D)").ToString.Trim

Regards
Sudharsan

Thanks for the reply.

Need small correction.

sfedf
1234 12134 52636
ecrr
wca
a12334 22\23 23345
24cr3
34ft4
\2334 22423 23\45dfjh
clsrhcueh
ytrfwvsydx: 25424 34874 8973|

From the above text its fetching a12334 22\23 as well as a result.

Hello @Manikandasamy

Have you got any more information on the pattern?

For me, the “24cr3” is troublesome…

Steve

Hey @Manikandasamy

Take a look at this pattern…

Hopefully its robust! :sweat_smile:

image

Regex pattern preview link

Hopefully this helps :blush:

Cheers

Steve

Hello @Manikandasamy
Try this

System.Text.RegularExpressions.Regex.Match(Youstr,"[\d \|\\]{10,20}").ToString.Trim

NOTE: Space should have between \d and \| in regex

Hi @Manikandasamy ,

Here is an alternative - we can replace the unwanted characters with null and keep whatever we need:

image

image

System.Text.RegularExpressions.Regex.Replace(str_1,"^[^\s]+\n",String.Empty,System.Text.RegularExpressions.RegexOptions.Multiline)

RegexMatchString.xaml (5.6 KB)

Kind Regards
Ashwin Ashok