I have a problem with regex. The variable media.Value
may contain the characters "() +" which causes an error in the regex and prevents it from working.
My code
Match renderMatch = Regex.Match(mediaMatch.Groups[0].Value, "(?<=\"name\":\"" + media.Value + "\",\"render\":).*?(?=,)");
Match mutedMatch = Regex.Match(mediaMatch.Groups[0].Value, "(?<=\"muted\":).*?(?=,\"name\":\"" + media.Value + "\")");
json I work with
[{"alignment":5,"cx":844.0,"cy":264.0,"id":4,"locked":false,"muted":false,"name":"Text (GDI +)","render":true,"source_cx":844,"source_cy":264,"type":"text_gdiplus_v2","volume":1.0,"x":549.0,"y":383.0},{"alignment":5,"cx":1920.0,"cy":1080.0,"id":3,"locked":false,"muted":false,"name":"Color","render":true,"source_cx":1920,"source_cy":1080,"type":"color_source_v3","volume":1.0,"x":0.0,"y":0.0}]
As long as there are no "()" in the name field everything works. For example:
Working
"muted":false,"name":"Color","render":true
Not working
"muted":false,"name":"Text (GDI +)","render":true
The question is. Is there any regex option that would ignore the () in string, or how else could I get an output like this:
"Text \(GDI \+\)"