mbercianop
(Mbercianop)
February 1, 2024, 8:12am
1
Hello everybody!
I have a question with regular expressions; I am trying to obtain the pattern for the examples:
9620314387631 LGF.pdf
9620252215751 NOV.pdf
and I have gotten a match → ^ [9]+\d{12}+[ ]+\w{2}[A-Za-z].pdf (in the web checker regex101.com ), but this same pattern is not validated in the web checker regexr.com (error with the + signs; I have tried replacing +[ ]+ with \s , but it does not detect the pattern either. This web always works for me).
It doesn’t work in my project either and I don’t quite understand how to get it.
Thanks in advance!
supriya117
(Supriya Allada)
February 1, 2024, 8:18am
2
Hi @mbercianop
Try this regex:
\d+\s\w+.pdf
or
\d{13}\s\w{3}.pdf
Use https://regexr.com/ website for regex.
Yoichi
(Yoichi)
February 1, 2024, 8:18am
3
Hi,
I think the pattern should be as the following.
^9\d{12} +\w{2}[A-Za-z]\.pdf
Can you check if you set .net(C#) mode in regex101?
Regards,
1 Like
Hi @mbercianop
\d{9,}\s[A-Z|a-z]+\.[A-Z|a-z]+
rlgandu
(Rajyalakshmi Gandu)
February 1, 2024, 8:19am
5
@mbercianop
System.Text.RegularExpressions.Regex.Match(InputString,"\d{8,}\s[A-Z]{3}\.[a-z]+").Value
Hi @mbercianop
\d{9,}\s[A-Z|a-z]+\.[A-Z|a-z]+
Hope it helps!!
mkankatala
(Mahesh Kankatala)
February 1, 2024, 8:23am
7
Hi @mbercianop
Simply use the below one
\d{12}\s+[A-Z]+.pdf
Select the multiline option in Flags dropwdown,
Hope it helps!!
vrdabberu
(Varunraj Dabberu)
February 1, 2024, 8:25am
8
Hi @mbercianop
^[9]+\d{12} \w{2}[A-Za-z].pdf
Regexr
Regex101
works fine in both websites.
Regards
pikorpa
(Piotr Kołakowski)
February 1, 2024, 8:25am
9
@mbercianop
you got several working solutions, so you can choose best one for you
My proposal:
^9\d{12} \w{3}.pdf
mbercianop
(Mbercianop)
February 1, 2024, 8:34am
11
Thank you all. It was also my lack of knowledge of configuration by not selecting C# (@Yoichi ) and multiline (@mkankatala ).
They all work correctly.
Have a great day!!
1 Like
mkankatala
(Mahesh Kankatala)
February 1, 2024, 8:35am
12
I hope you got the solution for your query. If yes make my post mark as solution to close the loop.
If you have any further queries, happy to help.
Happy Automation!!
system
(system)
Closed
February 4, 2024, 8:35am
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.