Hi all,
I have some string please check below:
-
eref+notprovided SVWZ+SABEN AQUELL . FACT. 1 047215
-
eref+2024/24fc/143 SVWZ+Abono de su factura 01 047184
-
eref+notprovided SVWZ+WONKA . FACT. 1047108 . 1047245 . 1047109
-
eref+notprovided DEBT+B31866551 SVWZ+PAGO FRA 01045354
I want to extract the invoice number. so my output should be below
1 047215
01 047184
1047108 . 1047245 . 1047109
01045354
I am trying the below pattern:
(\b\d{1,2}\s\d{6}\b)|(\b\d{1,2}\s\d{5}\b)|(\b\d{7}(?:\s.\s\d{7})+\b)
but it is working for the first three strings. for last one I could not able to extract the invoice no.
I would need your help and Kindly send one accurate regex pattern.
Thanks in advance.
Parvathy
(PS Parvathy)
2
Hi @roysupriya21
Regex Pattern: (?<=[A-Za-z]+.?)\s+\d+.*
Regards
1 Like
Hello @roysupriya21 ,
if you have this 4 string so you can use
Regards,
Dheerendra Vishwakarma
Hi @roysupriya21
you can use regular expression to extract invoice no from the following strings
System.Text.RegularExpressions.Regex.Match(inputString, “(?<=FACT.|FRA\s)([\d\s.]+)|(\b\d{2}\s\d+)”).Value.Trim()
(?<=FACT\.|FRA\s)
: Positive lookbehind to match either “FACT.” or "FRA " without including them in the match.
([\d\s.]+)
: Matches one or more digits, spaces, or dots.
|
: OR operator.
(\b\d{2}\s\d+)
: Matches two digits followed by a space and more digits, indicating an invoice number in the format “01 047184”.