B
B
bit_rainbow2015-09-10 01:13:50
Java
bit_rainbow, 2015-09-10 01:13:50

How to write Regexp with condition in Java?

I want to parse an SMS message using the sms parser program. It can parse regular expressions in java.
I don't have much experience in the regular season. That is why this question arose.
There is such text: "100.00UAH Znyattya
gotivki v bankomati WWWW, SSDSD 4
*35 12:11
Bal. 1111.52UAH" not static can be 1 or 2 or 3...). Can this be done regularly? If so, I'd love some help. I read about regular expressions with the condition, all I got was: pull out 1111.52UAH if there is 4*35". It is impossible to pull out 100.00UAH if there is 4*35.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
heartdevil, 2015-09-10
@bit_rainbow

Hello.
Try this regular expression
Not sure if it will work for java, since the online editor only has php/javascript/python
/([\d.]+UAH)[\s\S]+(?=(4\*35)) [\s\S]+\s(?(2)([\d.]+UAH))/
But it pulls out what you need from one sms
UPDATE:
This regular expression pulls out the sum in java
([\d .]+UAH)[\s\S]+(?=4\*35)[\s\S]+\s(?!4\*35)([\d.]+UAH)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question