Unwanted NSRegularExpression

I need NSRegularExpression, which is not greedy. You know, if there is:

ABABABA 

... and I ask that it matches B.*B I want him to capture the smallest possible match: BAB , not BABAB .

I’ve been looking at this problem for an hour now, and I continue to find links to the ICU / XCode regex implementation, maintaining unwanted matching, but for my life I can’t find the syntax to actually do it anywhere.

+4
source share
1 answer

Add a question mark:

 B.*?B 

See table 2 in the NSRegularExpression link

+14
source

Source: https://habr.com/ru/post/1397324/


All Articles