FROM : Vincent E.
DATE : Fri Jun 06 19:27:53 2008
When I mentioned "perl -pe 's/\b(.*?)/\u\L$1/g'" I actually wasn't
asking for any ObjC method with a look-alike syntax.
I actually wouldn't give a damn about "how" ("s///g") to pass a regex
pattern to a method. ;)
I was rather asking whether RegExKit (or even RegExKitLite?) would
generally be able to perform RegEx driven string replacements
where the replacement string contains stuff like "match back-
references" (\1, \2, \<named>, …) or string modificators like "\L, \U".
Now to answer my own question:
RegExKit has this function which (according to the documentation)
seems to do just what I was looking for:
[subjectString stringByMatching:regexString
withReferenceString:templateString];
And for the latter (\L, \U, etc) I unfortunately had to find this in
the PCRE documentation:
5. The following Perl escape sequences are not supported: \l, \u,
\L,
\U, and \N. In fact these are implemented by Perl's general
string-han-
dling and are not part of its pattern matching engine. If any
of these
are encountered by PCRE, an error is generated.
http://www.pcre.org/pcre.txt
Thanks a lot any way.
Vincent
On Jun 6, 2008, at 4:45 PM, Jason Stephenson wrote:
> Would something like this be acceptable?
>
> [someString replacePattern: @"\\b(.*?)" with: @"\\u\\L$1" flags:
> @"g"];
On Jun 6, 2008, at 6:16 PM, David Hoerl wrote:
>> dream cat7 wrote:
>>>
>> > 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 ?
DATE : Fri Jun 06 19:27:53 2008
When I mentioned "perl -pe 's/\b(.*?)/\u\L$1/g'" I actually wasn't
asking for any ObjC method with a look-alike syntax.
I actually wouldn't give a damn about "how" ("s///g") to pass a regex
pattern to a method. ;)
I was rather asking whether RegExKit (or even RegExKitLite?) would
generally be able to perform RegEx driven string replacements
where the replacement string contains stuff like "match back-
references" (\1, \2, \<named>, …) or string modificators like "\L, \U".
Now to answer my own question:
RegExKit has this function which (according to the documentation)
seems to do just what I was looking for:
[subjectString stringByMatching:regexString
withReferenceString:templateString];
And for the latter (\L, \U, etc) I unfortunately had to find this in
the PCRE documentation:
5. The following Perl escape sequences are not supported: \l, \u,
\L,
\U, and \N. In fact these are implemented by Perl's general
string-han-
dling and are not part of its pattern matching engine. If any
of these
are encountered by PCRE, an error is generated.
http://www.pcre.org/pcre.txt
Thanks a lot any way.
Vincent
On Jun 6, 2008, at 4:45 PM, Jason Stephenson wrote:
> Would something like this be acceptable?
>
> [someString replacePattern: @"\\b(.*?)" with: @"\\u\\L$1" flags:
> @"g"];
On Jun 6, 2008, at 6:16 PM, David Hoerl wrote:
>> dream cat7 wrote:
>>>
>> > 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 ?






Cocoa mail archive

