1

My string format is,

 {
     "group By": "name",
     "time Period": {
      "from": "2015-12-29",
      "to": "2016-02-29"
     },
     "query String": "[nation]: \"India\" AND [education]: \"be",
     "geography": "NA",
     "offset": 0,
     "limit": 10
 }

From the above content I want to extract the query string value and need to display it in HTML page.I have tried to do that using Regular expression in java net beans. But I am resulting in errors. Can you please give me the regex pattern to extract query string from the above JSON ?. The Regular expression I have tried is: \"((\"|[^"])*)\"";

Thanks in advance.

Jeya Suriya Muthumari
  • 1,947
  • 3
  • 25
  • 47

2 Answers2

3

You could try JSON parser instead of regex here. org.json library can be used.

Refer : http://www.tutorialspoint.com/json/json_java_example.htm

AVK
  • 213
  • 1
  • 7
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/11450182) – Bacteria Feb 29 '16 at 20:49
  • @UUIIUI This is not a link-only answer. – Rob Mar 01 '16 at 02:51
0

This is not the best approach. Try using some JSON parser library. If you still want to use regex, you can use the regex below:

\"query String\": \"(.*)\"

André Bonna
  • 807
  • 8
  • 13