Question

I need extract compile flags from xcodebuild output, So I want to get characters between "CompileC" and "-o"

I tried to do as in question described Regex Match all characters between two strings

I am using NSRegularExpression

CompileC.*?\-o  (match nothing)

CompileC.*?\-   (give characters between CompileC and first "-", but I need "-o")

it does not work, I had tried other versions, but i did not achieve good result.

How can I do that? what regexp should I use?

Update:

now works with NSRegularExpressionDotMatchesLineSeparators!

NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"CompileC.*?\-o "
                                                                       options:NSRegularExpressionDotMatchesLineSeparators
                                                                         error:&regexError];
Was it helpful?

Solution

CompileC.*?\-o should work. Make sure the dot can match newlines by activating this option in your regular expression constructor.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top