Search code examples
regexjsonparsingregular-language

How to parse Json using Regex?


I want to parse this json data with regex. But, i could not. I tried like this module.getid(.*), but no working.

Only, I want to take this part -> module.getid(...)

module.getid([{"id":"44423"}]); module.getresult([{"result":"false"}]);

How can i do it?


Solution

  • Try this if you want to capture the first (demo):

    /module.getid\((.*?)\); *module.getresult(?:.*?)\);$/m
    

    If you want to capture both json strings (demo):

    /module.getid\((.*?)\); *module.getresult(.*?)\);$/m