regex - Cocoa preg_split equivalent -



regex - Cocoa preg_split equivalent -

i'm using preg_split split string based on regular look in php, using next code:

$array = preg_split("~(?<!\*),~", $string);

what equivalent in cocoa?

any help appreciated.

ended writing own method using nsregularexpression

+ (nsarray *)preg_split:(nsstring *)expression withsubject:(nsstring *)subject { nsregularexpression *exp = [nsregularexpression regularexpressionwithpattern:expression options:0 error:nil]; nsarray *matches = [exp matchesinstring:subject options:0 range:nsmakerange(0, [subject length])]; nsmutablearray *results = [[nsmutablearray alloc] init]; (nstextcheckingresult *match in matches) { [results addobject:[subject substringwithrange:[match range]]]; } homecoming results; }

regex cocoa preg-split

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -