Hi everybody,
I need to extract a chain of character of a string.
For example this one : “LA SUPPLEMENTAIRE )LM RS RENTE PF161256980000-1589656-MARIE MADELEINE 20220401 LA MON”
I need to extract only the word which begin by “PF” + 8 digits.
In this case the output string must be “PF16125698”
Any idea please ?
Thank you
Hi @guillaume.cabanes2 ,
Could you try using the below Expression :
System.Text.RegularExpressions.Regex.Match(yourInputVar,"PF\d{8}").Value
Sanjit_Pal
(Sanjit Pal)
February 28, 2023, 5:06pm
3
Hey @guillaume.cabanes2 ,
You can use the below code
System.Text.RegularExpressions.Regex.Match(“LA SUPPLEMENTAIRE )LM RS RENTE PF161256980000-1589656-MARIE MADELEINE 20220401 LA MON”,“PF\d{8}”).Value
Thanks,
Sanjit
1 Like
Hi @guillaume.cabanes2
What about the following?
Regex.Match(strValue, "PF\d{8}").Value
Regards
Thank you so much both of them works well
Do you have an idea of how can i make sure that the 8 following characters (After “PF”) are digits please ?
Thank you
The “\d{8}” part of the Regex Provided before, is making sure that the pattern only returns something, if there are exactly 8 digits. If there are more, you can enhance it with \b at the end:
Regex.Match(strValue, “PF\d{8}\b”).Value
Exactly 8 digits:
Not matching if +8 digits (or -)
if instead of \d, you had \w, then you could have letters on it.
1 Like
system
(system)
Closed
March 6, 2023, 8:30am
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.