gokul1904
(Glory 01)
August 29, 2022, 5:50pm
1
Hi team ,
I want to extract “WEF0399876” from below examples -
FW: Fw: PCI SSC Invoice Enclosed - WEF0399876
aiagfajk asdh-jkkWEF0399876ds
FW: Fw: PCI SSC Invoice Enclosed - fsdfsWEF0399876 fwfggwg
basically WEF+“all integers till a space or non-integer comes”
this should not work for
4.FW: Fw: PCI SSC Invoice Enclosed - fsdfsWEFL0399876 fwfggwg
5.FW: Fw: PCI SSC Invoice Enclosed - fsdfsWEF023WEF0399876 fwfggwg (two WEFs in the same line)\
Regards,
Gokul
postwick
(Paul Ostwick)
August 29, 2022, 6:22pm
2
IF there is exactly 1 occurrence of WEF with a digit immediately after it, then extract the value. Else, there is either more than one WEF value, or it’s an invalid WEF (ie it doesn’t have a digit right after it “WEFL0399876”)
The regex expression in the Log Message is:
System.Text.RegularExpressions.Regex.Match(item,“(WEF[0-9]{7})”).ToString
Which will find WEF with 7 digits after it.
Here is an example output:
1 Like
Hey @gokul1904
You can start to learn Regex using my Regex MegaPost
Cheers
Steve
2 Likes
gokul1904
(Glory 01)
August 31, 2022, 7:12pm
4
Hi ,
There is no criteria of only 7 digits after WEF. It should pick up all the integers after WEF till a space/alphanumeric/non-integer value comes.
So can you please help me in modifying this -
System.Text.RegularExpressions.Regex.Match(item,“(WEF[0-9]{7})”).ToString
Regards,
G
postwick
(Paul Ostwick)
September 1, 2022, 12:34pm
5
Then just remove the 7 limitation and replace it with +
System.Text.RegularExpressions.Regex.Match(item,“(WEF[0-9]+)”).ToString
Gokul001
(Gokul Balaji)
September 1, 2022, 12:39pm
6
Hi @gokul1904
How about this expression?
System.Text.RegularExpressions.Regex.Match(YourString,"(WEF\S\d{6,7})").Tostring
Regards
Gokul
gokul1904
(Glory 01)
September 1, 2022, 1:25pm
8
Thank you , Will it pick up WEF048421135?
Gokul001
(Gokul Balaji)
September 1, 2022, 1:29pm
9
Hi @gokul1904
How about this expression?
System.Text.RegularExpressions.Regex.Match(YourString,"(WEF\S\d{6,9})").Tostring
Regards
Gokul
Gokul001
(Gokul Balaji)
September 1, 2022, 1:30pm
10
gokul1904:
WEF048421135
How many digit will appear after WEF ?
gokul1904
(Glory 01)
September 1, 2022, 6:58pm
11
its not constant.its dynamic.but it is
WEF(all integers till a noninteger/space comes)
Hello
Please try this:
System.Text.RegularExpressions.Regex.Match(item,“(WEF\d+)”).ToString
Cheers
Steve
1 Like
Gokul001
(Gokul Balaji)
September 2, 2022, 4:31am
14
Hi @gokul1904
Steven_McKeering:
(WEF\d+)”
This Patten will get WEF023 also in the input. How this will work for you? Have you handle with any kind of method?
How about this expression?
System.Text.RegularExpressions.Regex.Match(YourString,"(WEF\S\d{6,15})").Tostring
(WEF\S\d{6,15} → In this Expression you can change 15 into 100 so on. It will depends on the integer after WEF.
Regards
Gokul
Steven_McKeering:
WEF\d+
Ahhh @Gokul001 good pickup! I have missed that example, I wondered why everyone was overlooking that pattern
@gokul1904 - Lets try again to help you. You could try this pattern.
Or you could try one the above methods offered by @Gokul001 in their post. Otherwise, some more information / samples if they are not working.
Hopefully you have a pattern otherwise we will keep working on a pattern
Cheers
Steve
Gokul001
(Gokul Balaji)
September 2, 2022, 4:52am
16
Hi @gokul1904
How about this expression?
System.Text.RegularExpressions.Regex.Match(YourString,"(WEF\S\d+)(?=\s)|(WEF\S\d+)(?=[a-z])").Tostring
Regards
Gokul
1 Like
Hey @Gokul001
That could work but options 4 and 5 are not supposed to match - but can be with your pattern
Up to @gokul1904 …
Cheers
Steve
1 Like
gokul1904
(Glory 01)
September 2, 2022, 5:08am
18
Hey Gokul , that was a mistake from my end.I did not test the last 2 scenarios . Thanks for pointing it out.Now its resolved.
Thank you for all your efforts and inputs
Regards,
Gokul
Cool - glad you have your answer
If Option 4 isn’t supposed to match but Option 5 ideally is then take a look here .
Cheers
Steve
1 Like
system
(system)
Closed
September 5, 2022, 5:30am
20
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.