Reputation: 177
My response of an API is like "details" : "AccNo : 102478955441205" When i used "Regular Expression Extractor" to store the value in a variable it is successfully stored with the following regex "details"\s:\s*"([^"]*)" The problem is when I'm trying to use it, the response is coming as AccNo : 1010201213000005 but what i need is just the number. Can someone help me out
{ "statusCode" : "sfewr", "statusDes" : "Record inserted successfully!! ", "statusType" : "X", "details" : "AccNo : 102478955441205" }
"details"\s:\s*"([^"]*)"
"AccNo : 102478955441205"
102478955441205
Upvotes: 0
Views: 50
Reputation: 18357
You need to modify your regex a bit, so your group1 only matches the digits. You can use this regex,
"details"\s:\s*"\D*(\d+)"
I've used \D*
to match any non-digit text and have kept it out of first grouping pattern so your group1 contents are only digits. Also changed [^"]*
to \d+
as what you want to get in group1 is only digits. Although, if you want, you can retain [^"]*
too instead of \d+
Upvotes: 1