I need help with writing regular expression for this pattern in PHP:
[[{"type":"media","view_mode":"small","fid":"1","attributes":{"width":0,"height":0,"src":"http://localhost/x.png"}}]]
This is part of the text and I am trying to replace this by something else.
Would like to use preg_replace_all() but can’t figure out what would be the pattern. Any help appreciated.
Since you say you need to identify these JSON-strings inside a normal string, you could use this pattern:
meaning:
Because of the
sflag, the.in the regex will also match line breaks.Demo:
which will output: