Working on pure-ruby implementation of XCode project file parser, PBXProject, and need little help with regex.
So the PBXProject file has bunch of weird coed lines, which mixed contents. What I have now is regex, (.*?) = (.*?)( \/\* (.*) \*\/)?; ? which works on simpler cases (first line). But for second line, it cuts too early (to first ; -character).
isa = PBXBuildFile; fileRef = C0480C2015F4F91F00E0A2F4 /* zip.c */;
isa = PBXBuildFile; fileRef = C0480C2315F4F91F00E0A2F4 /* ZipArchive.mm */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; };
So what I want out of those lines are simple name = value pairs, i.e.
isa = PBXBuildFile
settings = {COMPILER_FLAGS = "-fno-objc-arc"; }
Easy way to achieve this with one regex?
This regex will work just fine:
Note that only one level of brackets is allowed, the regex will not process nested brackets.
From your example, the following lines will be catched:
Here’s the explanation of regex: