this is my first question, I really appreciate your help.
I need to extract data from a text. I use next pattern to obtain one or more numbers.
"6,5 I.G.I.C.[%: ]+([-]?\d{1,3}[.]\d{0,3}[.]\d{0,3}[,]\d{0,2}){1}([ ]+[-]?\d{1,3}[.]\d{0,3}[.]\d{0,3}[,]\d{0,2})?"
This is the text
SUBTOTAL: 400,00 € 6,5% I.G.I.C.: 26,00 € TEXT example6,5% I.G.I.C.: 26,00 € TOTAL: 42,00 €
The code I built makes regex with diferrent dynamic strings as initial part of the pattern needed to be located, "6,5 I.G.I.C." OR "5 I.G.I.C."
If I use "6,5 I.G.I.C.:" it return 2 matches (see atatched image) If I use "5 I.G.I.C." it returns the same 2 matches
There is anyway to obtain only the pattern when the string begin with the desired dynamic string. this way only 1 match will be detected as needed. Reading different Regex documents, explain that ^ allow to indicate the beginning of the string but I couldn't obtain the desired result.
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire