문제

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];
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top