Anonymous user
Regular expressions: Difference between revisions
objective-c matching
(objective-c matching) |
|||
Line 258:
// newSubject == "Replaced!"
var newSubject = subject.replace(re_PatternToMatch, "Replaced");
=={{header|Objective-C}}==
Test
{{works with|Mac OS X|10.4+}}
<lang objc>
NSString *str = @"I am a string";
NSString *regex = @".*string$";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
if ([pred evaluateWithObject:str]) {
NSLog(@"ends with 'string'");
}
</lang>
Unfortunately this method cannot find the location of the match or do substitution.
=={{header|OCaml}}==
|