Skip navigation.
 
mlRe: Regular Expressions?
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 ?

Related mailsAuthorDate
mlRegular Expressions? Cemil Browne Jun 6, 09:31
mlRe: Regular Expressions? Bob Warwick Jun 6, 09:55
mlRe: Regular Expressions? Bob Warwick Jun 6, 10:01
mlRe: Regular Expressions? David Troy Jun 6, 10:01
mlRe: Regular Expressions? Bill Bumgarner Jun 6, 10:08
mlRe: Regular Expressions? Citizen Jun 6, 10:11
mlRe: Regular Expressions? Cemil Browne Jun 6, 10:22
mlRe: Regular Expressions? Hamish Allan Jun 6, 11:08
mlRe: Regular Expressions? Allison Newman Jun 6, 11:10
mlRe: Regular Expressions? dream cat7 Jun 6, 11:34
mlRe: Regular Expressions? Vincent E. Jun 6, 12:01
mlRe: Regular Expressions? Jason Stephenson Jun 6, 12:23
mlRe: Regular Expressions? dream cat7 Jun 6, 14:09
mlRe: Regular Expressions? Vincent E. Jun 6, 15:39
mlRe: Regular Expressions? Dave DeLong Jun 6, 15:53
mlRe: Regular Expressions? dream cat7 Jun 6, 16:28
mlRe: Regular Expressions? Jason Stephenson Jun 6, 16:45
mlRe: Regular Expressions? Jason Stephenson Jun 6, 17:02
mlRe: Regular Expressions? Jens Alfke Jun 6, 17:03
mlRe: Regular Expressions? glenn andreas Jun 6, 17:13
mlRe: Regular Expressions? Jason Stephenson Jun 6, 17:29
mlRe: Regular Expressions? Jens Alfke Jun 6, 17:41
mlRe: Regular Expressions? dream cat7 Jun 6, 18:10
mlRe: Regular Expressions? David Hoerl Jun 6, 18:16
mlRe: Regular Expressions? Vincent E. Jun 6, 19:27
mlRe: Regular Expressions? James Montgomerie Jun 6, 20:19
mlRe: Regular Expressions? Jens Alfke Jun 6, 23:29
mlRe: Regular Expressions? Stephen J. Butler Jun 6, 23:47
mlRe: Regular Expressions? John C. Randolph Jun 7, 02:19
mlRe: Regular Expressions? Ilan Volow Jun 7, 12:41
ml3rd Party Nonsense (was Re: Regular Expressions?) Jason Stephenson Jun 7, 16:43
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Ken Ferry Jun 7, 18:59
mlRe: Regular Expressions? John Engelhart Jun 7, 19:07
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Kyle Sluder Jun 7, 19:24
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Kevin Grant Jun 7, 19:37
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) glenn andreas Jun 7, 20:01
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Michael Ash Jun 7, 20:27
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Torsten Curdt Jun 8, 00:44
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Mark Munz Jun 8, 01:19
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Michael Ash Jun 8, 12:39
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Jens Alfke Jun 10, 05:12
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Jens Alfke Jun 10, 05:17
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Adam R. Maxwell Jun 10, 05:56
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Mark Munz Jun 10, 06:12
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Stuart Malin Jun 10, 06:36
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Michael Ash Jun 10, 07:38
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Chris Ridd Jun 10, 16:16
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Jens Alfke Jun 10, 17:20
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Michael Ash Jun 10, 18:40
mlRe: 3rd Party Nonsense (was Re: Regular Expressions?) Alastair Houghton Jun 13, 13:36