Forum Discussion

plaidshirt's avatar
plaidshirt
Contributor
6 years ago

Get values multiple times from same tags

I try to match same regex multiple times on same SOAP response, it contains <ns12:AmountID> tag multiple times.

 

String numberToGet = reger.getNthMatch(/<ns12:AmountID>(\d+)<\/ns12:AmountID>/, 0);

 

How could I differ output values?

1 Reply

  • JHunt's avatar
    JHunt
    Community Hero

    Hi,

    Here's a Groovy example of how to get the value for multiple matches:

    assert ('abc1 def2 abc5 def6' =~ /abc(\d)/).findAll() == [['abc1', '1'], ['abc5','5']]