Re: Regular Expressions?
Re: Regular Expressions?
- Subject: Re: Regular Expressions?
- From: dream cat7 <email@hidden>
- Date: Fri, 6 Jun 2008 15:28:03 +0100
I agree that to be able to use that syntax is highly desirable, and
indeed missing from all the cocoa libraries that I have looked at. One
way would be a category addition to NSString class, which would call
the perl -pe 's/\b(.*?)/\u\L$1/g' for you and return the result as an
NSString...
But unfortunately nobody has come up that type of an extension to
NSString yet.
Or are there and c-libraries that will accept this s//// syntax ?
On 6 Jun 2008, at 14:39, Vincent E. wrote:
Right, but that's a very trivial string replacement with no advanced
modifications.
I had thing like this perl script for changing case to "word caps"
in mind:
echo 'some test text' | perl -pe 's/\b(.*?)/\u\L$1/g'
search pattern would be "\b(.*?)"
replacement pattern would be "\u\L$1"
I would need something with capabilities like these.
On Jun 6, 2008, at 2:09 PM, dream cat7 wrote:
No that would require finding rangeOfRegex followed by a call to
replaceCharactersInRange
NSRange range = [theString rangeOfRegex:@"regex" capture:0];
if( ! NSEqualRanges(range, ((NSRange){NSNotFound, 0} )) )
[theString replaceCharactersInRange:range withString:@"newstring"];
compare that to the RegexKit equivalent which is
- (NSString *)stringByMatching:(id)aRegex replace:(const
RKUInteger)count withReferenceFormat:(NSString *
const)referenceFormatString, ...;
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden