-1

I have a string.

String str= " <decision  CCDBNUM=\"1111111\" adddate=\"20180112\"><decision CCDBNUM=\"2222222\" adddate=\"20180114\"> ";

I want to write a regex to fetch a particular value from this string. My Expected Output is: to fetch only the value of CCDBNUM, i.e, 1111111 2222222

Please help me with this issue.

Richa Sharma
  • 75
  • 1
  • 9

1 Answers1

0

This should work:

CCDBNUM="([^"]+)"

Just get group 1 of each match.

I assume that CCDBNUM wouldn't contain the characters CCDBNUM. If that's not the case, I suggest you use an XML parser. Regex is not enough for that.

Demo

Sweeper
  • 213,210
  • 22
  • 193
  • 313