-3

My String: {“ID”:”NOKIA-71E1”,”KY”:”59ad728d99”,”U”:”admin”,”P”:”cfa522ec5a”,”S”:”FSH21290288A”,”23S”:”DC8D8A4171E1”,”N”:”5G12-13W-A”,”PN”:”3TG00799ABAA”,”IMEI”:”352778340662308”}

I need to get two outputs from the above string.

  1. The string after "s": which is FSH21290288A
  2. The string after "IMEI": which is 352778340662308
spinanoop
  • 3
  • 1

3 Answers3

0
(?<=[“”"]S[“”"]:[“”"])[^“”"]*(?=[“”"])
(?<=[“”"]IMEI[“”"]:[“”"])[^“”"]*(?=[“”"])

These experessions use lookahead and lookbehind groups, you can read more about them in this answer.

Alex Bochkarev
  • 2,851
  • 1
  • 18
  • 32
  • It's showing the correct output when I copied the input string and then copied the regex code you provided in https://regex101.com/. But not working with my VB code. I am using this pattern with VB – spinanoop Jan 23 '23 at 21:41
0

Without knowing what tools you are using here to be more specific, this regex will return the strings you need in the capture groups \1 and \2. See regex101 example here.

"S":"(.*?)".*"IMEI":"(.*?)".*
Gary_W
  • 9,933
  • 1
  • 22
  • 40
  • It's showing the correct output when I clicked the link you mentioned. But when I copied the input string and then copied the regex code you provided it's not giving any output. I am using this pattern with VB – spinanoop Jan 23 '23 at 21:33
0

Please make sure that quotes, In your question quotes and regex are same

Solution:

"S":"(?<S>.*?)".*"IMEI":"(?<IMEI>.*?)".*

Regex Link: enter link description here

Just FYI:

{“ID”:”NOKIA-71E1”,”KY”:”59ad728d99”,”U”:”admin”,”P”:”cfa522ec5a”,”S”:”FSH21290288A”,”23S”:”DC8D8A4171E1”,”N”:”5G12-13W-A”,”PN”:”3TG00799ABAA”,”IMEI”:”352778340662308”}

” - This quates in regex is diierent than the regex

" - This quates is in regex enter image description here