1
I’m needing my program to capture an item from a given text, but it’s not doing that, on the contrary, it’s capturing everything that comes after that.
Code I’m using, ex:
String html = "ItemPago12.569,00DeducoesPagas36.567,52ItensQnt6DeducoesRetidas21.354,11";
Pattern conteudo = Pattern.compile("ItemPago([^<]+)Deducoes");
Matcher match = conteudo.matcher(html);
match.find();
System.out.println(match.group(1));
Running program: https://ideone.com/JwFxu2
I need to get what’s in between: ItemPago
and Deducoes
. I would like examples and explanations of how to use this method correctly. Thank you.
Here your code works as expected: https://ideone.com/aPX7FP
– user28595
@Article It works because it is an example, but if I change the check string and put one more word "Deducoes" for example, it takes everything: https://ideone.com/JwFxu2
– neto schneider
It would then be interesting to edit and present the string that gives the error in the question, because the one that is not problems.
– user28595
@Articuno I just edited, so the problem becomes more evident...
– neto schneider