I´m trying to get out some value inside a text with regex.
Text example:
COMISION 002...................50.00........15.060000...............753.00 IVA 21 %
I would like to get: 753.00
I´m using this regex:
Pattern pattern = Pattern.compile("(?<=\\.\\.)(.*)(?=IVA 21 %)");
The problem is that this regex is outputting:
.................50.00........15.060000...............753.00
So I assume that the first time the engine finds the two dots (..) sets a limit.
What I want and can´t resolve is something like: "find the words "IVA 21 %", then look back and bring me all of the data till you see two dots together"
I´m new in the regex world so any help is appreciate.
You can use this regex to capture your number:
\\d+(?:\\.\\d+)?(?= IVA 21 %)
In your regex negative lookbehind (?<=\\.\\.)
will assert first two dots in the input that are right after 002
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.