Re: Why is / a metachar in regular expressions ?

2019-09-21 Thread Gabriel Zachmann via Cocoa-dev
>> 
>> Yeah, I'm inclined to think it's an error in the docs.
> 
> If you look at the input expression in this great site, you'll see 2 /'s as 
> part of it. They mark the beginning and the end (before flags).
> 
> https://regexr.com
> 

OTOH, the doc of  NSRegularExpression
specifically links to 
   http://userguide.icu-project.org/strings/regexp

And, as far as I can see, that does not talk about /


Best regards, Gabriel




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Why is / a metachar in regular expressions ?

2019-09-18 Thread Saagar Jha via Cocoa-dev
If you need any more confirmation, Swift’s NSRegularExpression escapes this 
exact set of characters 
,
 so there isn’t an error in the documentation. (NSRegularExpression in 
Foundation uses the same set, but it doesn’t go through this specific code path 
as far as I can tell.)

Saagar Jha

> On Sep 18, 2019, at 15:06, Rick Mann via Cocoa-dev 
>  wrote:
> 
> Ah! So it is. Definitely not an error in the docs, assuming 
> NSRegularExpression supports flags.
> 
>> On Sep 18, 2019, at 14:54 , Steve Mills via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>> 
>> On Sep 18, 2019, at 16:50:39, Rick Mann via Cocoa-dev 
>>  wrote:
>>> 
>>> Yeah, I'm inclined to think it's an error in the docs.
>> 
>> If you look at the input expression in this great site, you'll see 2 /'s as 
>> part of it. They mark the beginning and the end (before flags).
>> 
>> https://regexr.com
>> 
>> --
>> Steve Mills
>> Drummer, Mac geek
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/rmann%40latencyzero.com 
>> 
>> 
>> This email sent to rm...@latencyzero.com 
> 
> 
> -- 
> Rick Mann
> rm...@latencyzero.com 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com 
> )
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/saagar%40saagarjha.com 
> 
> 
> This email sent to saa...@saagarjha.com 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Why is / a metachar in regular expressions ?

2019-09-18 Thread Rick Mann via Cocoa-dev
Ah! So it is. Definitely not an error in the docs, assuming NSRegularExpression 
supports flags.

> On Sep 18, 2019, at 14:54 , Steve Mills via Cocoa-dev 
>  wrote:
> 
> On Sep 18, 2019, at 16:50:39, Rick Mann via Cocoa-dev 
>  wrote:
>> 
>> Yeah, I'm inclined to think it's an error in the docs.
> 
> If you look at the input expression in this great site, you'll see 2 /'s as 
> part of it. They mark the beginning and the end (before flags).
> 
> https://regexr.com
> 
> --
> Steve Mills
> Drummer, Mac geek
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/rmann%40latencyzero.com
> 
> This email sent to rm...@latencyzero.com


-- 
Rick Mann
rm...@latencyzero.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Why is / a metachar in regular expressions ?

2019-09-18 Thread Steve Mills via Cocoa-dev
On Sep 18, 2019, at 16:50:39, Rick Mann via Cocoa-dev 
 wrote:
> 
> Yeah, I'm inclined to think it's an error in the docs.

If you look at the input expression in this great site, you'll see 2 /'s as 
part of it. They mark the beginning and the end (before flags).

https://regexr.com

--
Steve Mills
Drummer, Mac geek

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Why is / a metachar in regular expressions ?

2019-09-18 Thread Rick Mann via Cocoa-dev
Yeah, I'm inclined to think it's an error in the docs.

> On Sep 18, 2019, at 14:43 , Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
>>> I don't see why / is a meta character.
>>> It does not appear anywhere else in the documentation as metacharacter.
>> 
>> In some languages "/" is used as the delimiter to begin/end a regular 
>> expression, for example in sed where the substitution command is 
>> "s/old/new/".
> 
> Right, good point - same in vi and vim (the editor).
> 
>> 
>> So perhaps the underlying regex parser ignores "/" characters at the 
>> start/end of the regex unless they're quoted?
> 
> Maybe, but I couldn't find any hint in the docs.
> 
> 
>> Is it used to refer to groups in text replacement? Sometimes that's a dollar 
>> sign, sometimes a slash, but I thought it was a backslash
> 
> Good point , but 
> -  IIRC, vim, at least, uses backslash for that, e.g., \1 ,\2, etc.;
> -  furthermore, NSRegularExpression does not do any text replacement by 
> itself, as far as I can see?
> 
> 
> Oh well, right now , I just don't escape any / , and it seems to work just 
> fine.
> 
> 
> Best regards, Gabriel
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/rmann%40latencyzero.com
> 
> This email sent to rm...@latencyzero.com


-- 
Rick Mann
rm...@latencyzero.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Why is / a metachar in regular expressions ?

2019-09-18 Thread Gabriel Zachmann via Cocoa-dev
>> I don't see why / is a meta character.
>> It does not appear anywhere else in the documentation as metacharacter.
> 
> In some languages "/" is used as the delimiter to begin/end a regular 
> expression, for example in sed where the substitution command is "s/old/new/".

Right, good point - same in vi and vim (the editor).

> 
> So perhaps the underlying regex parser ignores "/" characters at the 
> start/end of the regex unless they're quoted?

Maybe, but I couldn't find any hint in the docs.


> Is it used to refer to groups in text replacement? Sometimes that's a dollar 
> sign, sometimes a slash, but I thought it was a backslash

Good point , but 
-  IIRC, vim, at least, uses backslash for that, e.g., \1 ,\2, etc.;
-  furthermore, NSRegularExpression does not do any text replacement by itself, 
as far as I can see?


Oh well, right now , I just don't escape any / , and it seems to work just fine.


Best regards, Gabriel



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Why is / a metachar in regular expressions ?

2019-09-18 Thread Rick Mann via Cocoa-dev
Is it used to refer to groups in text replacement? Sometimes that's a dollar 
sign, sometimes a slash, but I thought it was a backslash.

> On Sep 18, 2019, at 13:51 , Jens Alfke via Cocoa-dev 
>  wrote:
> 
> 
> 
>> On Sep 18, 2019, at 1:45 PM, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> I don't see why / is a meta character.
>> It does not appear anywhere else in the documentation as metacharacter.
> 
> In some languages "/" is used as the delimiter to begin/end a regular 
> expression, for example in sed where the substitution command is "s/old/new/".
> 
> So perhaps the underlying regex parser ignores "/" characters at the 
> start/end of the regex unless they're quoted?
> 
> —Jens
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/rmann%40latencyzero.com
> 
> This email sent to rm...@latencyzero.com


-- 
Rick Mann
rm...@latencyzero.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Why is / a metachar in regular expressions ?

2019-09-18 Thread Jens Alfke via Cocoa-dev


> On Sep 18, 2019, at 1:45 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I don't see why / is a meta character.
> It does not appear anywhere else in the documentation as metacharacter.

In some languages "/" is used as the delimiter to begin/end a regular 
expression, for example in sed where the substitution command is "s/old/new/".

So perhaps the underlying regex parser ignores "/" characters at the start/end 
of the regex unless they're quoted?

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Why is / a metachar in regular expressions ?

2019-09-18 Thread Gabriel Zachmann via Cocoa-dev
In the doc for NSRegularExpression, it says

   "Characters that must be quoted to be treated as literals are * ? + [ ( ) { 
} ^ $ | \ . / "

I don't see why / is a meta character.
It does not appear anywhere else in the documentation as metacharacter.

(Also not at http://userguide.icu-project.org/strings/regexp , which is 
referenced in the 
doc for NSRegularExpression )

Can anyone shed light on this?

Best regards, Gabriel



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: SETUP : Regular Expressions - Easy Setup for RegexKitLite

2010-05-18 Thread Scott Ribe
On May 15, 2010, at 6:02 PM, Jens Alfke wrote:

> FYI, you don’t have to edit the linker flags anymore to do this. In Xcode 
> 3.1+ you can open the target inspector, choose the General tab, and click the 
> + button at the bottom left to pop up a list of available libraries. Then 
> choose “libicucore.dylib”.

Or, if you like to keep a group for the libraries you've added where you can 
see what's what, right click the group, select Add -> Existing Frameworks, and 
choose the library.

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: SETUP : Regular Expressions - Easy Setup for RegexKitLite

2010-05-15 Thread Bill Hernandez
On May 15, 2010, at 7:02 PM, Jens Alfke wrote:

> FYI, you don’t have to edit the linker flags anymore to do this. In Xcode 
> 3.1+ you can open the target inspector, choose the General tab, and click the 
> + button at the bottom left to pop up a list of available libraries. Then 
> choose “libicucore.dylib”.

Jens,

Thanks a million, I am almost sensing that you are becoming my mentor. It's 
nice having someone out there trying to keep you from committing some massive 
buffoonery, thank you. I mean well, but my knowledge and experience just aren't 
there...

I added your comments to the notes on the page, and took a couple of additional 
screen captures that shows what you shared.

Correction made :

 
http://www.journey-of-flight.com/bh_xcode/common/regex_kit_lite/regex_kit_lite_install.php

 Under : 
 Some Feedback

Best Regards,

Bill Hernandez
Plano, Texas___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: SETUP : Regular Expressions - Easy Setup for RegexKitLite

2010-05-15 Thread Jens Alfke

On May 15, 2010, at 2:15 PM, Bill Hernandez wrote:

> finally remembered that I had to add -licucore to the other linker flags.
> I decided to make a few screen captures (10) that make it really easy to see 
> the small change that needs to be made to each project that uses regular 
> expressions.

FYI, you don’t have to edit the linker flags anymore to do this. In Xcode 3.1+ 
you can open the target inspector, choose the General tab, and click the + 
button at the bottom left to pop up a list of available libraries. Then choose 
“libicucore.dylib”.

—Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


SETUP : Regular Expressions - Easy Setup for RegexKitLite

2010-05-15 Thread Bill Hernandez
I've been using RegexKitLite for regular expressions for a little while, and 
the other day when I went to add it to another project, I had forgotten about 
the project setup. I was getting debugging errors, and finally remembered that 
I had to add -licucore to the other linker flags.

I decided to make a few screen captures (10) that make it really easy to see 
the small change that needs to be made to each project that uses regular 
expressions.

It is really simple and makes coding much easier than by using some of the 
Cocoa methods for similar tasks.

It is listed under :

RegexKitLite Quick Setup

http://www.journey-of-flight.com/bh_xcode/common/regex_kit_lite/regex_kit_lite_install.php

I also updated :

Cocoa, Xcode, Objective C - Useful Resources...

http://www.journey-of-flight.com/bh_xcode/common/cocoa_programming_resources.php


I added a couple of really neat tools that make life much easier.

Hope some of this is helpful.

Best Regards,

Bill Hernandez
Plano, Texas___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Regular Expressions

2010-02-22 Thread Jens Alfke
If you need more flexibility, you can write a short script in a language like 
Ruby, Perl or Python to do it. The advantage is that you can use arbitrarily 
powerful string and logical operators to transform the match string before 
replacing it. Perl and Ruby both have a command-line flag that says "run the 
script on every line of input" so you can pretty much do this as a one-liner. 
(I'd show you an example but I haven't touched Ruby in about a year so it's 
gotten paged out of my working memory...)

You can then add the script to Xcode's script menu, or invoke it as a 
run-script build phase.

—Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Regular Expressions

2010-02-22 Thread Dave DeLong
(([a-z]{2})[a-z]*) ([0-9]+):([0-9]+)

The name of the book is in \1, the first two letters are in \2, and then the 
reference is in \3:\4

However, this does require that the name of the book be at least two letters 
long.

Dave

On Feb 22, 2010, at 8:08 AM, Philip Juel Borges wrote:

> Hi,
> 
> Xcode supports the use of regular expressions. With the following search and 
> replace I can find a string, like John 17:17, and turn it into a link:
> 
> Find
> ([a-z]+) ([0-9]+):([0-9]+)
> 
> Replace
> \1 \2:\3
> 
> This works fine. But right after Library I want to insert another folder 
> comprised of the first two letters of John. So after the search and replace 
> I'd like to get:
> 
> John 17:17
> 
> Is it possible in the replace field to extract the first two letters of the 
> first pattern, i.e., ([a-z]+)?
> 
> --Philip


smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Regular Expressions

2010-02-22 Thread Philip Juel Borges

Hi,

Xcode supports the use of regular expressions. With the following  
search and replace I can find a string, like John 17:17, and turn it  
into a link:


Find
([a-z]+) ([0-9]+):([0-9]+)

Replace
\1 \2:\3

This works fine. But right after Library I want to insert another  
folder comprised of the first two letters of John. So after the search  
and replace I'd like to get:


John 17:17

Is it possible in the replace field to extract the first two letters  
of the first pattern, i.e., ([a-z]+)?


--Philip
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and Regular Expressions

2009-12-14 Thread Dave DeLong
RegexKit is the best (read: simplest) way to get regular expression support 
into your Cocoa apps.  http://regexkit.sourceforge.net  It's also possible to 
use NSPredicate for simple matching.

You can find a couple of other options listed on this page:  
http://cocoaheads.byu.edu/resources/regex

Cheers,

Dave

On Dec 14, 2009, at 3:34 PM, Phil Hystad wrote:

> I was sort of suspecting that regular expression matches would be supported 
> by NSString yet I find no message interface for supporting regular 
> expressions.  So, is the only capability for handling regular expressions in 
> Objective-C the Posix Regex library?


smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSString and Regular Expressions

2009-12-14 Thread Phil Hystad
I was sort of suspecting that regular expression matches would be supported by 
NSString yet I find no message interface for supporting regular expressions.  
So, is the only capability for handling regular expressions in Objective-C the 
Posix Regex library?

phil
phys...@mac.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: AGRegex (was: NSString and regular expressions)

2009-08-03 Thread Adam R. Maxwell


On Aug 3, 2009, at 8:15 PM, BareFeet wrote:


Has anyone got procedure for getting AGRegex to work in their project?


I've used AGRegex.framework in a number of projects, but it's been so  
long that I've no idea what steps I went through to set it up.  The  
copy here


https://tcobrowser.svn.sourceforge.net/svnroot/tcobrowser/trunk/bibdesk/vendorsrc/agkit_sourceforge/agregex

should work as-is, provided you set up Xcode's prefs with a separate  
directory for built products and intermediate files.  It also has a  
few bug fixes.  General framework compilation problems are probably  
better addressed on the xcode-users list.


--
Adam



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: AGRegex (was: NSString and regular expressions)

2009-08-03 Thread Rick Mann
I gave up on AGRegex and used RegexKit, which was very easy to get to  
work.


On Aug 3, 2009, at 20:15:18, BareFeet wrote:


Hi all,

Has anyone got procedure for getting AGRegex to work in their project?

Thanks,
Tom
BareFeet


From: BareFeet 
Date: 31 July 2009 9:03:20 AM AEST
To: Cocoa Dev 
Subject: Re: NSString and regular expressions

Hi Rob,


I personally just compile the files directly into my project.

You need AGRegex.h and AGRegex.m but you should only compile the  
following files from the pcre distribution:


pcre_chartables.c
pcre_compile.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_info.c
pcre_ord2utf8.c
pcre_tables.c
pcre_try_flipped.c
pcre_ucp_searchfuncs.c
pcre_valid_utf8.c
pcre_xclass.c


Thanks. I tried that, but get 436 fails during compile, starting  
with "pcre.h: No such file or directory."


So I copied pcre.h across to my project too but then get more errors  
starting with "pcre_internal.h No such file or directory."


If I add all the header files, I still get compile errors, starting  
with:


pcre_ucp_searchfuncs.c:48:54:
error: ucptable.c: No such file or directory

So I copied ucptable.c but I get the error:

ucptable.c:4:
error: expected '=', ',', ';', 'asm' or '__attribute__' before  
'ucp_table'


Can you please clue me in as to how to get AGRegex to work?

Thanks,
Tom
BareFeet


From: BareFeet 
Date: 30 July 2009 2:51:59 PM AEST
To: Cocoa-dev 
Subject: Re: NSString and regular expressions

Hi Rob & all,

On 28/07/2009, at 11:02 AM, Rob Keniger wrote:

You might want to look at AGRegex which is very compact (one class)  
and which uses PCRE:


http://colloquy.info/project/browser/trunk/Frameworks/AGRegex


Thanks for the tip. Have you been able to get this to work?

Do we add the framework or the AGRegex files (and PCRE folder) to  
our own project? I've tried both and can't get it to work. I can't  
find any instructions in the documentation on adding it correctly to  
your own project.


Thanks,
Tom
BareFeet
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/rmann%40latencyzero.com

This email sent to rm...@latencyzero.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


AGRegex (was: NSString and regular expressions)

2009-08-03 Thread BareFeet

Hi all,

Has anyone got procedure for getting AGRegex to work in their project?

Thanks,
Tom
BareFeet

 
From: BareFeet 
Date: 31 July 2009 9:03:20 AM AEST
To: Cocoa Dev 
Subject: Re: NSString and regular expressions

Hi Rob,


I personally just compile the files directly into my project.

You need AGRegex.h and AGRegex.m but you should only compile the  
following files from the pcre distribution:


pcre_chartables.c
pcre_compile.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_info.c
pcre_ord2utf8.c
pcre_tables.c
pcre_try_flipped.c
pcre_ucp_searchfuncs.c
pcre_valid_utf8.c
pcre_xclass.c


Thanks. I tried that, but get 436 fails during compile, starting with  
"pcre.h: No such file or directory."


So I copied pcre.h across to my project too but then get more errors  
starting with "pcre_internal.h No such file or directory."


If I add all the header files, I still get compile errors, starting  
with:


pcre_ucp_searchfuncs.c:48:54:
 error: ucptable.c: No such file or directory

So I copied ucptable.c but I get the error:

ucptable.c:4:
 error: expected '=', ',', ';', 'asm' or '__attribute__' before  
'ucp_table'


Can you please clue me in as to how to get AGRegex to work?

Thanks,
Tom
BareFeet

 
From: BareFeet 
Date: 30 July 2009 2:51:59 PM AEST
To: Cocoa-dev 
Subject: Re: NSString and regular expressions

Hi Rob & all,

On 28/07/2009, at 11:02 AM, Rob Keniger wrote:

You might want to look at AGRegex which is very compact (one class)  
and which uses PCRE:


http://colloquy.info/project/browser/trunk/Frameworks/AGRegex


Thanks for the tip. Have you been able to get this to work?

Do we add the framework or the AGRegex files (and PCRE folder) to our  
own project? I've tried both and can't get it to work. I can't find  
any instructions in the documentation on adding it correctly to your  
own project.


Thanks,
Tom
BareFeet
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-08-03 Thread BareFeet

Hi All,

RegexKitLite looks promising. It claims to only require you to add  
the .h and .m file to your project and link to the libicucore.dylib  
library.


I managed to incorporate RegexKitLite fairly easily once I found in  
the documentation the steps to link to the libicucore.dylib library.


Thanks for all your comments about ICU vs PCRE. I've thrown a couple  
of fairly involved regexes at it that I've previously used in Perl  
(therefore PCRE) and haven't had to make any adjustments at all.


I've wrapped it in a test Cocoa app that shows capture in an outline  
view, with each group showing as a child item of its capture. It's  
working very well so far. The essence of my use of RegexKitLite here is:


- (IBAction)update:(id)sender
{
NSString * regexString = [regexField string];
NSString * inputString = [inputField string];

	[outputArray release]; // already defined as an instance variable in  
the .h file

NSError * myError = nil;
NSRange myRange = NSMakeRange(0, [inputString length]);
	outputArray = [inputString  
arrayOfCaptureComponentsMatchedByRegex:regexString  
options:RKLNoOptions range:myRange error:&myError];

[outputArray retain];
[outputOutline reloadData];
}
@end

I'm new to Cocoa and Objective-C. So please tell me gently of any  
glaring errors above


Now to use it in my real project, I need to port over my routines that  
parsed SQL statements. I have been doing this by:


1. Using regex to replace quoted items (eg bounded by " or ' or a  
comment bounded by /* */ or -- \n) with placeholders.


2. Using regex to parse the SQL (now containing placeholders) into  
desired SQL components


3. Replacing placeholders with original text.

Before I go ahead and port this same method across, is there any built  
in functionality in Cocoa that will facilitate this (or part of it)  
directly?


Thanks,
Tom
BareFeet

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-31 Thread John Engelhart
On Thu, Jul 30, 2009 at 8:04 PM, BareFeet wrote:

> Hi John and all,
>
>  You might want to look at AGRegex which is very compact (one class) and
>>> which uses PCRE:
>>>
>>> http://colloquy.info/project/browser/trunk/Frameworks/AGRegex
>>>
>>>
>> Of note, Colloquy appears to have switched to RegexKitLite itself:
>>
>> http://svn.colloquy.info/project/changeset/4301
>
>
Just to be clear, I'm the author of RegexKitLite (and RegexKit.framework).
 I just like to be up front about that so you can apply whatever amount of
bias filtering you want to any claims or statements I make.


> <http://svn.colloquy.info/project/changeset/4301>
>
> I did notice that log entry, but thought it was never acted upon (ie they
> are still using AGRegex).


I can't say I did any kind of exhaustive check, but I was under the
impression that they had definitely switched over.  I even got a bug report
from them.


>
> RegexKitLite looks promising. It claims to only require you to add the .h
> and .m file to your project and link to the libicucore.dylib library.
>
> The documentation notes: "Warning: Apple does not officially support
> linking to the libicucore.dylib library." In reality, how worried should I
> be about this? I am amazed that Cocoa doesn't provide regex itself. Surely
> Apple must provide or recommend something to do the job.


wrt/ to linking to libicucore.dylib, that's kind of a grey area.  I try to
be as up front as possible about that fact in the documentation.  What
follows is my opinion and carries no official weight.  So far as I know it's
an accurate representation of the facts, and I've tried to keep it
objective:

The shared library that causes the controversy is /usr/lib/libicucore.dylib.
 I've searched the documentation and I could find nothing that explicitly
forbids linking against it, or anything else in /usr/lib.  If one subscribes
to the common unix traditions, the /usr/lib directory is generally
considered "fair game" for linking against- it is one of the common
locations for a systems publicly available shared libraries.  By placing a
library in /usr/lib, one implicitly declares it "publicly available".

The next stumbling block is the need for headers.  A default install of Mac
OS X does not include the ICU headers one would normally need to make use of
the ICU library.  However, the ICU project is an open source project, so one
can (easily?) assemble a suitable set of headers if one is so inclined.  Not
only that, but Apple provides a tar ball of their branch of ICU that is used
to build the binaries that are present on every Mac OS X system.
 Furthermore, that tar balls make file includes a target to install the ICU
headers on your system.  Although a bit convoluted to actually get, Apple
does publicly provide the headers for the ICU library.  See
http://www.opensource.apple.com/tarballs/ICU/ for the tar balls.

After that, the next criteria is whether or not the API is documented.  It's
safe to say that the ICU API is documented, although not by Apple.  Apple
actually refers to the ICU documentation in certain parts of its official
documentation (NSPredicate wrt/ regular expressions and the MATCHES
operator).

So, it comes down to a matter of opinion and a judgement call.  Considering
how easy it is to create a location in the file system that makes it clear
that the shared libraries within are private, I'm of the opinion that the
/usr/lib/libicucore.dylib file is definitely in the public category.  Even
private frameworks have their own slice in
/System/Library/PrivateFrameworks, which makes it pretty clear that the
contents within are off-limits.  Even within public frameworks their is the
PrivateHeaders folder for non-public API information.

Up next is whether or not the lack of headers makes the library "private".
 If this was a proprietary library, I'd probably lean towards "makes it
private".  However, it's a publicly available open-source project, so it
becomes a little more grey.  The fact that Apple publicly provides
everything needed to build an exact copy of the version of ICU that's
shipped with system, and the ability to install the headers makes it really
grey.  Personally, I'm inclined to say that it's in the "not private"
category.  I think it's fair to say that the "undocumented API" clause
doesn't apply.

Finally, I'm not aware of any official decrees that explicitly make
/usr/lib/libicucore.dylib a "private API".  What advice that has come from
Apple has been extremely ambiguous, usually with a caveat along the lines of
"this may not be officially supported".

>From a purely pragmatic perspective, it makes a lot of sense for Apple to
provide the headers and make it an "Off

Re: NSString and regular expressions

2009-07-31 Thread Alastair Houghton

On 31 Jul 2009, at 15:30, Jean-Daniel Dupas wrote:


Le 31 juil. 09 à 11:30, Alastair Houghton a écrit :

As far as I understood, the original reason for not providing the  
headers was that the C++ ABI was not stable and so a program linked  
against ICU on one version of Mac OS X might not work on a  
subsequent version (assuming it went and used the C++ API).


This is also true for the C API.


Well not quite.  The C *API* might be non-binary-compatible if you  
built ICU the wrong way, and some sections of it are certainly marked  
as stable/unstable.  But I was specifically talking about the Mac OS X  
C++ *ABI*, which IIRC was still in flux when this question first  
appeared.


Anyway, we're in danger of drifting off topic here.

Kind regards,

Alastair.

--
http://alastairs-place.net



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-31 Thread Jean-Daniel Dupas


Le 31 juil. 09 à 11:30, Alastair Houghton a écrit :


On 31 Jul 2009, at 01:04, BareFeet wrote:

The documentation notes: "Warning: Apple does not officially  
support linking to the libicucore.dylib library." In reality, how  
worried should I be about this?


I wouldn't lose much sleep over it, to be honest, as long as you  
stick to ICU's C API (as opposed to the C++ part).


As far as I understood, the original reason for not providing the  
headers was that the C++ ABI was not stable and so a program linked  
against ICU on one version of Mac OS X might not work on a  
subsequent version (assuming it went and used the C++ API).


This is also true for the C API. From the ICU user guide:
ICU Binary Compatibility: Using ICU as an Operating System Level Library

ICU4C may be configured for use as a system library in an environment  
where applications that are built with one version of ICU must  
continue to run without change with later versions of the ICU shared  
library.


Here are the requirements for enabling binary compatibility for ICU4C:

Applications must use only APIs that are marked as stable.

Applications must use only plain C APIs, never C++.

ICU must be built with function renaming disabled.

Applications must be built using an ICU that was configured for binary  
compatibility.


Use ICU version 3.0 or later.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-31 Thread Alastair Houghton

On 31 Jul 2009, at 01:18, Charles Srstka wrote:

ICU is an open-source project, so if you're concerned about the  
Apple-supplied one disappearing, you can just go download the latest  
sources, compile it yourself, and then either link it statically or  
include the dylib inside your bundle.


http://site.icu-project.org/


This is all true, but it is worth pointing out that ICU includes a  
data file that contains (amongst other things) time zone data, Unicode  
data, localisation information and other stuff.


The issue there is that *occasionally* the data file needs updating.   
For instance when some politician decides that now would be a good  
time to change the time zone rules for the United States (as happened  
recently).  Or when the Unicode specification is revised or bugs are  
found in the CLDR data.  If you have multiple copies of ICU, each one  
will need updating separately... and because the ICU data file is  
version specific to some extent, you can't necessarily share the data.


You can avoid this, for the most part, by using Core Foundation or  
Cocoa where possible, since that will use the system's copy of the  
data which will at least result in consistent behaviour.  But if you  
use ICU directly, or rely on something that does, and you choose to  
bundle ICU with your application, you should be aware of this issue.


Kind regards,

Alastair.

--
http://alastairs-place.net



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-31 Thread Alastair Houghton

On 31 Jul 2009, at 01:04, BareFeet wrote:

The documentation notes: "Warning: Apple does not officially support  
linking to the libicucore.dylib library." In reality, how worried  
should I be about this?


I wouldn't lose much sleep over it, to be honest, as long as you stick  
to ICU's C API (as opposed to the C++ part).


As far as I understood, the original reason for not providing the  
headers was that the C++ ABI was not stable and so a program linked  
against ICU on one version of Mac OS X might not work on a subsequent  
version (assuming it went and used the C++ API).  I don't know why the  
headers still aren't shipped with OS X...



I guess I can deal with that.

Has anyone discovered any other issues (or had successes) dealing  
with ICU syntax in RegexKitLite and RegexKitLite in general?


ICU's regexp engine is pretty complete, though it doesn't have:

1. Named capture groups; e.g. in Python you can do

  (?P[a-zA-Z0-9]*)

and you can then retrieve the capture by name rather than by index.   
This is a very useful feature as it lets you alter your regexp without  
having to renumber everything.


You can also do backrefs to named capture groups (in Python) using e.g.

  (?P=myGroup)

Again, this makes it easier to change your regexp without breaking  
everything.


2. Conditional expressions, e.g.

  (?(myGroup)then-part|else-part)

The above would match the text "then-part" *if* a group named  
"myGroup" had already matched, otherwise it would match "else-part".   
You can also use a number rather than a name to identify the match  
group, and lookahead/lookbehind expressions are supported in there also.


I wrote and submitted a patch some time ago to add these features to  
ICU.  I don't know why but it doesn't seem to have made it back to the  
main source tree.  If anyone is interested in these extras, they're  
here (though that patch was generated against ICU 3.6):


  http://alastairs-place.net/2006/09/icu-regular-exp/

There are open tickets in the ICU bug tracker (#2907 and #5312) that  
refer to these.


Kind regards,

Alastair.

--
http://alastairs-place.net



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-30 Thread Charles Srstka

On Jul 30, 2009, at 7:04 PM, BareFeet wrote:

RegexKitLite looks promising. It claims to only require you to add  
the .h and .m file to your project and link to the libicucore.dylib  
library.


The documentation notes: "Warning: Apple does not officially support  
linking to the libicucore.dylib library." In reality, how worried  
should I be about this? I am amazed that Cocoa doesn't provide regex  
itself. Surely Apple must provide or recommend something to do the  
job.


ICU is an open-source project, so if you're concerned about the Apple- 
supplied one disappearing, you can just go download the latest  
sources, compile it yourself, and then either link it statically or  
include the dylib inside your bundle.


http://site.icu-project.org/

Charles
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-30 Thread BareFeet

Hi John and all,

You might want to look at AGRegex which is very compact (one class)  
and which uses PCRE:


http://colloquy.info/project/browser/trunk/Frameworks/AGRegex



Of note, Colloquy appears to have switched to RegexKitLite itself:

http://svn.colloquy.info/project/changeset/4301


I did notice that log entry, but thought it was never acted upon (ie  
they are still using AGRegex).


RegexKitLite looks promising. It claims to only require you to add  
the .h and .m file to your project and link to the libicucore.dylib  
library.


The documentation notes: "Warning: Apple does not officially support  
linking to the libicucore.dylib library." In reality, how worried  
should I be about this? I am amazed that Cocoa doesn't provide regex  
itself. Surely Apple must provide or recommend something to do the job.


As quoted earlier:

Unfortunately, RegexKit Lite (the stripped-down version) uses the  
built-in ICU library which uses a syntax quite different to the  
PCRE that most people are used to.


At first glance through the "ICU Syntax" documentation included with  
RegexKitLite, it appears the same as what I'm used to. At least it  
supports \s for whitespace, \w for words, (?=...) for look ahead. I  
did, however, discover:



Single Quote
Two single quotes represent a single quote, either inside or outside  
single quotes. Text within single quotes is not interpreted in any  
way, except for two adjacent single quotes. It is taken as literal  
text— special characters become non-special. These quoting  
conventions for ICU character classes differ from those of Perl or  
Java. In those environments, single quotes have no special meaning,  
and are treated like any other literal character.


I guess I can deal with that.

Has anyone discovered any other issues (or had successes) dealing with  
ICU syntax in RegexKitLite and RegexKitLite in general?


Thanks,
Tom
BareFeet

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-30 Thread BareFeet

Hi Rob,


I personally just compile the files directly into my project.

You need AGRegex.h and AGRegex.m but you should only compile the  
following files from the pcre distribution:


pcre_chartables.c
pcre_compile.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_info.c
pcre_ord2utf8.c
pcre_tables.c
pcre_try_flipped.c
pcre_ucp_searchfuncs.c
pcre_valid_utf8.c
pcre_xclass.c


Thanks. I tried that, but get 436 fails during compile, starting with  
"pcre.h: No such file or directory."


So I copied pcre.h across to my project too but then get more errors  
starting with "pcre_internal.h No such file or directory."


If I add all the header files, I still get compile errors, starting  
with:


pcre_ucp_searchfuncs.c:48:54:
  error: ucptable.c: No such file or directory

So I copied ucptable.c but I get the error:

ucptable.c:4:
  error: expected '=', ',', ';', 'asm' or '__attribute__' before  
'ucp_table'


Can you please clue me in as to how to get AGRegex to work?

Thanks,
Tom
BareFeet

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-30 Thread John Engelhart
On Mon, Jul 27, 2009 at 9:02 PM, Rob Keniger  wrote:

>
> On 28/07/2009, at 10:38 AM, Dave DeLong wrote:
>
>  RegexKit.  Without a doubt.
>>
>> http://regexkit.sourceforge.net
>>
>> I use it in about 75% of my projects.
>>
>
> RegexKit is very nice and extremely comprehensive, but it has quite a large
> footprint and is probably overkill for many uses.
>
> Unfortunately, RegexKit Lite (the stripped-down version) uses the built-in
> ICU library which uses a syntax quite different to the PCRE that most people
> are used to.
>
> You might want to look at AGRegex which is very compact (one class) and
> which uses PCRE:
>
> http://colloquy.info/project/browser/trunk/Frameworks/AGRegex
>

Of note, Colloquy appears to have switched to RegexKitLite itself:

http://svn.colloquy.info/project/changeset/4301
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-30 Thread Rob Keniger


On 30/07/2009, at 2:51 PM, BareFeet wrote:

You might want to look at AGRegex which is very compact (one class)  
and which uses PCRE:


http://colloquy.info/project/browser/trunk/Frameworks/AGRegex


Thanks for the tip. Have you been able to get this to work?

Do we add the framework or the AGRegex files (and PCRE folder) to  
our own project? I've tried both and can't get it to work. I can't  
find any instructions in the documentation on adding it correctly to  
your own project.



I personally just compile the files directly into my project.

You need AGRegex.h and AGRegex.m but you should only compile the  
following files from the pcre distribution:


pcre_chartables.c
pcre_compile.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_info.c
pcre_ord2utf8.c
pcre_tables.c
pcre_try_flipped.c
pcre_ucp_searchfuncs.c
pcre_valid_utf8.c
pcre_xclass.c



--
Rob Keniger



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-29 Thread BareFeet

Hi Rob & all,

On 28/07/2009, at 11:02 AM, Rob Keniger wrote:

You might want to look at AGRegex which is very compact (one class)  
and which uses PCRE:


http://colloquy.info/project/browser/trunk/Frameworks/AGRegex


Thanks for the tip. Have you been able to get this to work?

Do we add the framework or the AGRegex files (and PCRE folder) to our  
own project? I've tried both and can't get it to work. I can't find  
any instructions in the documentation on adding it correctly to your  
own project.


Thanks,
Tom
BareFeet

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-28 Thread jonat...@mugginsoft.com


On 28 Jul 2009, at 10:26, Alastair Houghton wrote:


On 28 Jul 2009, at 02:02, Rob Keniger wrote:


On 28/07/2009, at 10:38 AM, Dave DeLong wrote:


RegexKit.  Without a doubt.

http://regexkit.sourceforge.net

I use it in about 75% of my projects.


RegexKit is very nice and extremely comprehensive, but it has quite  
a large footprint and is probably overkill for many uses.


Unfortunately, RegexKit Lite (the stripped-down version) uses the  
built-in ICU library which uses a syntax quite different to the  
PCRE that most people are used to.


Since the goal in both ICU and PCRE is to be broadly compatible with  
Perl regular expression syntax, I think it's an exaggeration to say  
that the syntax is "quite different".  There are things in PCRE that  
aren't supported in ICU, and vice-versa.  And neither of them  
support everything that is implemented in Perl (partly because you'd  
have to actually *implement* Perl to do it).



NSPredicate anyone?
The MATCHES operator uses ICU's Regular Expressions package.
http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/Articles/pUsing.html#/ 
/apple_ref/doc/uid/TP40001794-SW9

Kind regards,

Alastair.

--
http://alastairs-place.net



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/jonathan%40mugginsoft.com

This email sent to jonat...@mugginsoft.com


Jonathan Mitchell

Developer
http://www.mugginsoft.com





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-28 Thread Alastair Houghton

On 28 Jul 2009, at 02:02, Rob Keniger wrote:


On 28/07/2009, at 10:38 AM, Dave DeLong wrote:


RegexKit.  Without a doubt.

http://regexkit.sourceforge.net

I use it in about 75% of my projects.


RegexKit is very nice and extremely comprehensive, but it has quite  
a large footprint and is probably overkill for many uses.


Unfortunately, RegexKit Lite (the stripped-down version) uses the  
built-in ICU library which uses a syntax quite different to the PCRE  
that most people are used to.


Since the goal in both ICU and PCRE is to be broadly compatible with  
Perl regular expression syntax, I think it's an exaggeration to say  
that the syntax is "quite different".  There are things in PCRE that  
aren't supported in ICU, and vice-versa.  And neither of them support  
everything that is implemented in Perl (partly because you'd have to  
actually *implement* Perl to do it).


Kind regards,

Alastair.

--
http://alastairs-place.net



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-27 Thread Rob Keniger


On 28/07/2009, at 10:38 AM, Dave DeLong wrote:


RegexKit.  Without a doubt.

http://regexkit.sourceforge.net

I use it in about 75% of my projects.


RegexKit is very nice and extremely comprehensive, but it has quite a  
large footprint and is probably overkill for many uses.


Unfortunately, RegexKit Lite (the stripped-down version) uses the  
built-in ICU library which uses a syntax quite different to the PCRE  
that most people are used to.


You might want to look at AGRegex which is very compact (one class)  
and which uses PCRE:


http://colloquy.info/project/browser/trunk/Frameworks/AGRegex

--
Rob Keniger



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString and regular expressions

2009-07-27 Thread Dave DeLong

RegexKit.  Without a doubt.

http://regexkit.sourceforge.net

I use it in about 75% of my projects.

Dave

On Jul 27, 2009, at 6:37 PM, Rick Mann wrote:

I need to do some regex searches on NSStrings, and use capturing  
groups. Looking online I found some discussions from 2003 referring  
to MOKit, which hasn't been touched since 2005, and seems to include  
a lot of stuff I don't care about. Other references to agkit suggest  
it doesn't support unicode.


All of this makes me wonder if there's not a better support in this  
day and age for regex? I'm surprised not to find it in NSString.


Recommendations on what I should use? Thanks!


--
Rick

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com

This email sent to davedel...@me.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSString and regular expressions

2009-07-27 Thread Rick Mann
I need to do some regex searches on NSStrings, and use capturing  
groups. Looking online I found some discussions from 2003 referring to  
MOKit, which hasn't been touched since 2005, and seems to include a  
lot of stuff I don't care about. Other references to agkit suggest it  
doesn't support unicode.


All of this makes me wonder if there's not a better support in this  
day and age for regex? I'm surprised not to find it in NSString.


Recommendations on what I should use? Thanks!


--
Rick

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-13 Thread Alastair Houghton

On 10 Jun 2008, at 15:16, Chris Ridd wrote:


On 10 Jun 2008, at 05:12, Mark Munz wrote:


Just wishing for the problem to go away or blaming external criteria
will almost guarantee that nothing gets done. Filing bugs is how you,
the developer, communicate your needs to Apple.


Since ICU is open source, the other productive thing to do would be  
to give the ICU folks a hand at writing whatever bits of gunk are  
required by Apple.


"The ICU folks" actually includes Apple, since they have at least one  
person working on ICU (IIRC ICU was one of the results of Apple's  
collaboration with IBM on Taligent).  As I understand it, the main  
reason it isn't fully exposed is that ICU is primarily a C++ library  
and there have and continue to be binary compatibility issues with C++  
APIs.


I think Apple is likely to add CFRegularExpression and a bridged  
NSRegularExpression at some point, and very probably a load of CF/ 
NSString and NSScanner APIs to go with them, but it isn't a trivial  
amount of work and I imagine they will want to think it through  
carefully before deciding on the API, not to mention the supported  
regexp syntax(es).  By contrast, most of the regexp frameworks  
currently available are thin wrappers around an existing regular  
expression engine and have been knocked up quickly to fill a need.   
More thought needs to go into a system API and since CFStrings can  
exist in a number of different internal storage formats it may even  
make sense for Apple to do its own regexp implementation to achieve  
the best performance.


Anyway, all of that is up to them.  As others have said, filing bug  
reports is the way to push for this work if you want it done.  Whether  
working on ICU or not will make things happen faster is something that  
only people inside Apple could tell us.  My guess is that it won't  
make any difference, but it's just a guess.


Kind regards,

Alastair.

--
http://alastairs-place.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-10 Thread Michael Ash
On Tue, Jun 10, 2008 at 8:20 AM, Jens Alfke <[EMAIL PROTECTED]> wrote:
>
> On 9 Jun '08, at 10:38 PM, Michael Ash wrote:
>
>> It's perfectly possible to write safe code that calls C
>> str functions. My code is no more vulnerable than the next man's. You
>> can call things like strnstr, pass the length of the NSData you're
>> working on, and there is exactly zero risk of anything.
>
> Sure, and it's perfectly possible to shave with a blade without cutting
> yourself; that doesn't mean it doesn't happen, though :/ What you're saying
> is "if you do everything right, there's zero risk of it being wrong", which
> is a tautology. The point is that people can and do make mistakes when
> working with C string APIs (even the "n" ones).

This is true but meaningless. People can and do make mistakes with
*everything*. The C string APIs don't have a particularly special
place as far as security vulnerabilities go.

>> No, it's not. A common technique is to use C string APIs to find line
>> endings, then try the full line as UTF-8. If it fails, then you can
>> fall back on a more forgiving encoding.
>
> Yes, I do try UTF-8 first. Sorry, I was being brief in the previous message,
> describing only the _fallback_ if UTF-8 parsing fails.
>
> I'm not sure why you would want to use C APIs to look for line endings
> first, though?

When working with streaming data then you need to find a delimiter to
safely cut the stream before trying UTF-8, because if the end of your
chunk of data ends in the middle of a UTF-8 code word (or whatever
it's called), then the result will be invalid UTF-8 even if the stream
as a whole is valid UTF-8. You could write a UTF-8 parser to find good
cut points, but it's much easier when working with a line-oriented
protocol to just look for CRLF.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-10 Thread Jens Alfke


On 9 Jun '08, at 10:38 PM, Michael Ash wrote:


It's perfectly possible to write safe code that calls C
str functions. My code is no more vulnerable than the next man's. You
can call things like strnstr, pass the length of the NSData you're
working on, and there is exactly zero risk of anything.


Sure, and it's perfectly possible to shave with a blade without  
cutting yourself; that doesn't mean it doesn't happen, though :/ What  
you're saying is "if you do everything right, there's zero risk of it  
being wrong", which is a tautology. The point is that people can and  
do make mistakes when working with C string APIs (even the "n" ones).



No, it's not. A common technique is to use C string APIs to find line
endings, then try the full line as UTF-8. If it fails, then you can
fall back on a more forgiving encoding.


Yes, I do try UTF-8 first. Sorry, I was being brief in the previous  
message, describing only the _fallback_ if UTF-8 parsing fails.


I'm not sure why you would want to use C APIs to look for line endings  
first, though?


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-10 Thread Chris Ridd


On 10 Jun 2008, at 05:12, Mark Munz wrote:


Just wishing for the problem to go away or blaming external criteria
will almost guarantee that nothing gets done. Filing bugs is how you,
the developer, communicate your needs to Apple.


Since ICU is open source, the other productive thing to do would be to  
give the ICU folks a hand at writing whatever bits of gunk are  
required by Apple.


Cheers,

Chris
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-09 Thread Michael Ash
On Mon, Jun 9, 2008 at 8:17 PM, Jens Alfke <[EMAIL PROTECTED]> wrote:
>
> On 8 Jun '08, at 3:39 AM, Michael Ash wrote:
>
>> I do this with a fair amount of regularity. NSString is unsuitable for
>> working with data whose encoding is unknown or doubtful, and NSData
>> doesn't have any string-like functionality, so the standard C str
>> functions can be very useful here.
>
> Ouch. The problem with those is that, every time you call one, you've added
> a potential buffer overrun bug to your app. And if the data in the string
> came from an untrusted source like the network, that escalates to a
> potential security vulnerability.

Sorry, what? It's perfectly possible to write safe code that calls C
str functions. My code is no more vulnerable than the next man's. You
can call things like strnstr, pass the length of the NSData you're
working on, and there is exactly zero risk of anything.

> Also, speaking of doubtful encodings, the regular C string functions will
> fail quite badly on 16-bit character encodings, where it's more than likely
> that every other byte is a zero.

While true, this is also irrelevant when you know that your data is
not, in fact, 16-bit. I use this technique when the data is known to
be ASCII-like but exactly what kind of ASCII-like encoding is unknown.
It would be nonsensical to use it for UTF-16 data, and thus I don't.

> My general tactic when dealing with unknown data whose encoding can't be
> determined is to just fall back on CP-1252 [though Aki Inoue suggested
> MacRoman], both of which are supersets of ascii that map every byte to a
> character. That way you'll always get a non-nil NSString, and any ascii text
> in the original will come out unscathed. That's a better result than you'll
> get with C string APIs.

No, it's not. A common technique is to use C string APIs to find line
endings, then try the full line as UTF-8. If it fails, then you can
fall back on a more forgiving encoding. This will give correct results
for UTF-8, which in many cases is the expected encoding, which is very
nice to have. Turning well-formed UTF-8 text into long strings of
nonsense characters is generally undesirable. It also has an extremely
low probability of false positives, as it's difficult to construct a
sensible string in a different encoding which is also valid UTF-8. The
fallback guarantees that you can at least try something if you get
data that you don't expect.

You may not be familiar with this technique but that doesn't mean it's
bad. It's good and useful in many situations.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-09 Thread Stuart Malin


On Jun 9, 2008, at 9:11 PM, Adam R. Maxwell wrote:



I thought I read on the Xcode users list that Xcode is using ICU for
regex find-and-replace, so it's too bad the rest of us can't use it.


I recall the same. And further, I am of the understanding that  
NSPredicate uses ICU for its pattern matching -- can anyone confirm?


~~~

For another regex solution, take a look at Objective PCRE:

http://sourceforge.net/projects/objpcre

For my regex needs, I link in libpcre and use objpcre as the "glue."

objpcre accepts NSString objects for both the regular expression and  
the string to be evaluated. Whether (or how) this UTF-16 string is  
converted to UTF-8 (which, I believe, is native encoding for pcre),  
happens behind the scenes, and so is "invisible" to me.


FWIW. HTH.








___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-09 Thread Mark Munz
On 6/9/08, Adam R. Maxwell <[EMAIL PROTECTED]> wrote:
>
>  Unfortunately, I think filing bug reports on this is a waste of time at
> this point.  I'm still using AGRegex, which is based on a pretty ancient
> PCRE, but it's predated by (at least) MOKit and OFRegularExpression:

Filing bugs against this *IS NOT* a waste of time. Please don't
discourage people from letting Apple know that this is an important
issue for the developers. If a large number of developers file bugs
against this, it lets Apple know that this is an area that deserves
more resources and attention.

Just wishing for the problem to go away or blaming external criteria
will almost guarantee that nothing gets done. Filing bugs is how you,
the developer, communicate your needs to Apple.

Apple engineers have ALWAYS encourage me to log bugs against issues I
mentioned to them, even if they are duplicates.

-- 
Mark Munz
unmarked software
http://www.unmarked.com/
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-09 Thread Adam R. Maxwell


On Jun 9, 2008, at 8:12 PM, Jens Alfke wrote:


On 7 Jun '08, at 10:24 AM, Kyle Sluder wrote:


1) There are certain basics like regex support that people are upset
at Apple for not implementing because it seems like such an important
part of the concept of strings.


Agreed, and I made this argument many times while there. Part of the  
problem is the impedance mismatch issue — Apple would want to use  
ICU because of its good Unicode support, but the way the ICU APIs  
are written generally requires copying the string to a temporary  
buffer (especially if you consider thread-safety.) There has been  
talk of extending ICU regexps to support plug-in string storage,  
which would be more efficient, and as far as I can tell, the whole  
regexps-for-Cocoa feature gets hung up on waiting for that, year  
after year.


Is this the ICU problem you're talking about?

http://lists.apple.com/archives/Cocoa-dev/2007/Sep/msg00416.html

I thought I read on the Xcode users list that Xcode is using ICU for  
regex find-and-replace, so it's too bad the rest of us can't use it.


Unfortunately, I think filing bug reports on this is a waste of time  
at this point.  I'm still using AGRegex, which is based on a pretty  
ancient PCRE, but it's predated by (at least) MOKit and  
OFRegularExpression:


http://www.omnigroup.com/mailman/archive/macosx-dev/1998-December/006560.html

So this has been a recurring theme for a few years now...

--
Adam___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-09 Thread Jens Alfke


On 8 Jun '08, at 3:39 AM, Michael Ash wrote:


I never cared about the lack of regex support personally, although I
understand that people do use them. As far as a blessed solution goes,
"man regex" gives you a library that's in libSystem and is part of
POSIX, so it's as supported as you can get.


And (as discussed a few weeks ago) it's not Unicode-savvy, which could  
bite the unwary developer in the ass, especially when attempting to  
localize their app into non-Roman languages like Japanese.



I do this with a fair amount of regularity. NSString is unsuitable for
working with data whose encoding is unknown or doubtful, and NSData
doesn't have any string-like functionality, so the standard C str
functions can be very useful here.


Ouch. The problem with those is that, every time you call one, you've  
added a potential buffer overrun bug to your app. And if the data in  
the string came from an untrusted source like the network, that  
escalates to a potential security vulnerability.


Also, speaking of doubtful encodings, the regular C string functions  
will fail quite badly on 16-bit character encodings, where it's more  
than likely that every other byte is a zero.


My general tactic when dealing with unknown data whose encoding can't  
be determined is to just fall back on CP-1252 [though Aki Inoue  
suggested MacRoman], both of which are supersets of ascii that map  
every byte to a character. That way you'll always get a non-nil  
NSString, and any ascii text in the original will come out unscathed.  
That's a better result than you'll get with C string APIs.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-09 Thread Jens Alfke


On 7 Jun '08, at 10:24 AM, Kyle Sluder wrote:


1) There are certain basics like regex support that people are upset
at Apple for not implementing because it seems like such an important
part of the concept of strings.


Agreed, and I made this argument many times while there. Part of the  
problem is the impedance mismatch issue — Apple would want to use ICU  
because of its good Unicode support, but the way the ICU APIs are  
written generally requires copying the string to a temporary buffer  
(especially if you consider thread-safety.) There has been talk of  
extending ICU regexps to support plug-in string storage, which would  
be more efficient, and as far as I can tell, the whole regexps-for- 
Cocoa feature gets hung up on waiting for that, year after year.


Filing bugs on it is going to annoy people on the Cocoa team at Apple  
because they'll have to flag them all as dups and send them back; but  
it's the only lever that's been given to 3rd party developers to  
influence this, so I can't fault anyone for yanking it.



4) Linking against a third-party framework requires distributing the
framework inside the app bundle.  Look at the proliferation of
Sparkle.framework to see why this is a Bad Thing(TM).


Not if it's in the OS, which most all of the regexp libraries are. (I  
know, you mean the Obj-C adapter framework, but in the case of  
RegexpKit-Lite that's just one class / source file, which I don't see  
as a problem. Just statically link it into your app.)


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-08 Thread Michael Ash
On Sat, Jun 7, 2008 at 7:19 PM, Mark Munz <[EMAIL PROTECTED]> wrote:
> On 6/7/08, Michael Ash <[EMAIL PROTECTED]> wrote:
>
>>  Of course Mac OS X does come with a regex library, it just doesn't
>>  have an ObjC interface. There's more to what's available than Cocoa,
>>  and one of the great things about ObjC is how easy it is to talk to
>>  these pure C libraries and get them to do work for you as well.
>
> Many folks see regular expressions as a core part of today's
> frameworks (.NET, Java, Ruby, Python). ObjC, admittedly, looks a bit
> anemic in this area. There is no blessed solution and so the developer
> is required to research each of the many libraries to consider their
> pros and cons. Apple provides some libraries, but doesn't support
> linking against them (like ICU, which is used by Apple in Xcode but
> we've been told don't link against the system library).

I never cared about the lack of regex support personally, although I
understand that people do use them. As far as a blessed solution goes,
"man regex" gives you a library that's in libSystem and is part of
POSIX, so it's as supported as you can get.

> While it is always possible to drop down to the pure C libraries, I
> see that is an unnecessary step and akin to asking Cocoa developers to
> use C libraries to do string manipulation.

I do this with a fair amount of regularity. NSString is unsuitable for
working with data whose encoding is unknown or doubtful, and NSData
doesn't have any string-like functionality, so the standard C str
functions can be very useful here.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-07 Thread Mark Munz
On 6/7/08, Michael Ash <[EMAIL PROTECTED]> wrote:

>  Of course Mac OS X does come with a regex library, it just doesn't
>  have an ObjC interface. There's more to what's available than Cocoa,
>  and one of the great things about ObjC is how easy it is to talk to
>  these pure C libraries and get them to do work for you as well.

Many folks see regular expressions as a core part of today's
frameworks (.NET, Java, Ruby, Python). ObjC, admittedly, looks a bit
anemic in this area. There is no blessed solution and so the developer
is required to research each of the many libraries to consider their
pros and cons. Apple provides some libraries, but doesn't support
linking against them (like ICU, which is used by Apple in Xcode but
we've been told don't link against the system library).

While it is always possible to drop down to the pure C libraries, I
see that is an unnecessary step and akin to asking Cocoa developers to
use C libraries to do string manipulation.

For everyone that would like to see Apple add support for regex into
the Cocoa frameworks, I highly recommend filing a bug via
http://bugreporter.apple.com to let Apple know that they need to
assign some engineering effort to this issue.

-- 
Mark Munz
unmarked software
http://www.unmarked.com/
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread Torsten Curdt

Here is one: Integration with other languages

Java's integration with other languages (as using Java libraries in
other languages) is about one of the worse I've ever seen. It
basically makes any Java library accessible to only Java.


Yepp - the integration sucks but...


And a second one: Performance


...when was the last time you tried java?

Really depends on what you are up to. The generality of this statement  
disqualifies it.


cheers
--
Torsten
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread Torsten Curdt


On Jun 7, 2008, at 07:38, Jose Raul Capablanca wrote:


Allison Newman said:

It's just that I can't help thinking about all of the comments that  
we see on this list from people coming from Java or some other  
language where header files aren't necessary, or which don't have  
pointers.  They are confused by these things, and having to learn  
that at the same time as learning Cocoa itself makes for a very  
steep learning curve.


Indeed.

I was one of the Java people you referred to. Nowadays, my day-time  
job is game programming in C and I dabble on Objective-C/Cocoa when  
time permits, so I think I've now gotten used to header files and  
pointers. But those things still feel to me as nothing more than  
fossils.


Yepp - C was the first language I learned. So quite used to it as  
well. But still - header files are fossils. Totally agree.


cheers
--
Torsten
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread Philippe Mougin


Le 7 juin 08 à 22:26, WT a écrit :

I still don't see any good-enough *technical* reason to justify  
basing Cocoa on an extension of C, however. That's all I've been  
trying to say.


WT, I think this is an interesting question (as are your other  
comments), and I think I have the answer :-)
The thing is that Mac OS X is a UNIX system and C is the native  
language on UNIX (in part because UNIX is itself implemented in C).  
Therefore, C based languages (i.e., C, ObjC and C++) have a very  
synergistic relationship with the OS, at the technical level.
There have been several serious initiatives to provide new  
environments based on other languages (from ADA back in the early  
eighties to Java more recently) , but so far none has been able to  
displace C-based languages for application development on UNIX based  
systems, except in the field of in-house enterprise applications or in  
very specific niches.
For instance, look at the  "SUN Java Desktop System", which  
constitutes user-facing layers of Solaris 10, including a complete  
application suite. Despite its name, it is nearly entirely developed  
in C/C++.
For better or worse, it seems that, as a general rule, the language in  
which a given OS is implemented is also the most technically apt for  
application development on that OS. This might not hold true forever,  
of course. But, in the meantime, I think we are certainly very lucky  
to be stuck with Objective-C, which is a surprisingly efficient and  
powerful combination of C and Smalltalk. You'll see that with the new  
automatic garbage collection in Objective-C 2.0, the main development  
productivity weakness with regard to languages like Java has been  
lifted.


Philippe
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-07 Thread Torsten Curdt



Agree with your sentiments. Not everything needs to be shipped by  
default.


The only other environment where I've programmed that this same  
attitude may rear its head could be Java land, but even there that  
attitude does not seem to rear its head quite so often as it seems  
to on this list.


N...java did start shipping more and more stuff included over the  
years. It's also the huge amount of 3rd party libraries that makes is  
so appealing to so many people. But for some reason I still found it  
easier to find my way through the options available.


Actually java even provides good examples where 3rd parties are be  
better than inclusions. Thinking of Crimson and the logging  
API ...sure there is even more.


Anyway this is getting OT

cheers
--
Torsten

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread John C. Randolph


On Jun 7, 2008, at 7:38 AM, Jose Raul Capablanca wrote:

I never understood why Apple stopped supporting the Java bridge to  
Cocoa.



Two reasons:  First, not enough people were using it to make it cost- 
effective to maintain, and second, it was sucking up a lot of  
development time when new classes were added to the frameworks.   
Java's fundamental deficiencies make it far more difficult to bridge  
than Ruby and Python.


The Java bridge came into existence for political reasons, and those  
political reasons have become moot.


-jcr


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread John C. Randolph
I didn't say not to use Ruby if you want.  What I took exception to is  
your statement that "you don't have to fully learn Objective-C's  
syntax at the same time as Cocoa".   Use whatever language you like,  
but if you're going to use Cocoa, you'd *better* learn Objective-C.


-jcr

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread WT

On Jun 7, 2008, at 9:01 PM, Felipe Monteiro de Carvalho wrote:

On Sat, Jun 7, 2008 at 11:38 AM, Jose Raul Capablanca <[EMAIL PROTECTED] 
> wrote:

With the exception of the id and SEL types,
categories, and the fact that you can send messages to nil, I can't  
think of

anything in Obj-C that isn't done better in Java,


Here is one: Integration with other languages

Java's integration with other languages (as using Java libraries in
other languages) is about one of the worse I've ever seen. It
basically makes any Java library accessible to only Java.


That's not really relevant to the point I was trying to make. Besides,  
how good is Obj-C's integration with other languages in the same sense  
you're referring to above? Can Obj-C libraries be used in other  
languages? I don't think so.



And a second one: Performance


Again, that's irrelevant, since OS X applications aren't cross- 
platform. Java applications built to run only on Macs can be compiled  
natively. Moreover, a performance argument can also be made against  
Ruby and Python and, yet, there *are* Cocoa bridges for those languages.



If people are going to ditch Java as a contender for a native language  
for Cocoa (in a parallel universe, of course), they should do it for  
the right technical reasons (in addition to the right non-technical  
ones). As Michael Ash pointed out, Java's object model is not  
perfectly matched with Cocoa's, and that's a reasonable argument.


I still don't see any good-enough *technical* reason to justify basing  
Cocoa on an extension of C, however. That's all I've been trying to say.


Wagner
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread WT

Michael Ash said:

I disagree with your assessment that there's nothing in ObjC that  
isn't done better in Java


If you read my message again, I think you'll see that I didn't go as  
far as to say that, or even to suggest it. In fact, I explicitly  
mentioned features of Obj-C that are useful, and non-existing in Java.


The fact is that ObjC's C nature is an enormous advantage, not a  
disadvantage as you paint it.


Once again, I think you undeservedly interpreted my words in an  
extreme way. I didn't paint Obj-C's C nature as being intrinsically a  
disadvantage. I merely voiced my opinion that notions such as header  
files, pointers, and manual memory management are things of the past.  
Having said that, I *do* think that exposing pointers and requiring  
programmers to manually manage memory *are* major disadvantages these  
days, when applications are bigger and more intricate than ever. How  
many hours of debugging time have been spent tracking memory problems  
due to mismanaged pointers?


...the C integration brings enormous foibles. But that same C  
integration also brings enormous advantages.


As with anything, it always boils down to a trade-off. Integrating  
Cocoa with  would have its own  
trade-offs as well.


You can directly call any C-based library on the system, which is  
essentially all of them. You can drop in any portable C or C++ code  
you happen to have, which is often a lot.


The existence of a large library base is also true of Java. Since  
every copy of OS X comes with Java built-in, one has access to a large  
number of well-tested libraries. Case in point: dealing with regular  
expressions (a recent hot topic in this list).



I don't mean to make a case explicitly for Java (or to make a case at  
all - I'm just voicing an opinion, not making a request for Apple to  
change anything!). The bigger point I was trying to make is that, as  
with any language, there are design choices in C that years of  
practice have shown to have been poor choices. Unfortunately for us,  
we're stuck with them because Obj-C sits on top of C.


All I was trying to convey with my previous message is the suspicion  
that Apple would choose a different native language for Cocoa if they  
were to wipe the slate clean and redesign Cocoa from scratch, knowing  
what we all know today. I say that because of the OO additions (and  
garbage collection in Obj-C 2.0), because there really isn't anything  
in C that is essential for Cocoa to work, and because C brings with it  
features that are either pretty much useless (such as header files) or  
annoying to deal with (such as include cycles) or downright dangerous  
(pointers and manual memory management).



Wagner

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread Felipe Monteiro de Carvalho
On Sat, Jun 7, 2008 at 11:38 AM, Jose Raul Capablanca <[EMAIL PROTECTED]> wrote:
> With the exception of the id and SEL types,
> categories, and the fact that you can send messages to nil, I can't think of
> anything in Obj-C that isn't done better in Java,

Here is one: Integration with other languages

Java's integration with other languages (as using Java libraries in
other languages) is about one of the worse I've ever seen. It
basically makes any Java library accessible to only Java.

And a second one: Performance

-- 
Felipe Monteiro de Carvalho
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-07 Thread Michael Ash
On Sat, Jun 7, 2008 at 10:43 AM, Jason Stephenson <[EMAIL PROTECTED]> wrote:
> It seems that many on this list feel that Apple should provide everything
> that the programmer needs to work on Mac OS X and that there should not be
> 3rd party frameworks for much of anything.
>
> This attitude really, truly puzzles me because on every other platform where
> I've programmed this attitude never came up in the discussion forums. It was
> always just assumed that you would need to use 3rd party frameworks to get
> any real work done, unless you intended to roll everything yourself.

I think it's because Cocoa provides so much, but falls short in some
strange places. You can easily get used to having Cocoa do all the
work for you. XML parsing? Check. HTTP handling? Check. Media
decoding? Check. Speech synthesis? Check. Regular expressions? Doh!

Of course Mac OS X does come with a regex library, it just doesn't
have an ObjC interface. There's more to what's available than Cocoa,
and one of the great things about ObjC is how easy it is to talk to
these pure C libraries and get them to do work for you as well.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread Michael Ash
On Sat, Jun 7, 2008 at 10:38 AM, Jose Raul Capablanca <[EMAIL PROTECTED]> wrote:
> I know that Obj-C is more dynamic than Java (and that's quite important for
> Cocoa to work its magic), but if Apple had never developed Cocoa and were to
> do it now, from scratch, I doubt that they would choose to do it in a
> language that sits atop of C. With the exception of the id and SEL types,
> categories, and the fact that you can send messages to nil, I can't think of
> anything in Obj-C that isn't done better in Java, with the added benefits
> that Java has no header files, no include cycles, no pointers, and has
> automatic memory management that works (judging from another thread in this
> list, garbage collection in Obj-C 2.0 has some wrinkles).

I disagree with your assessment that there's nothing in ObjC that
isn't done better in Java, but that's neither here nor there. The fact
is that ObjC's C nature is an enormous advantage, not a disadvantage
as you paint it. Standing alone, ObjC is at most a mediocre language.
(Here come the flames) It adds nothing particularly remarkable
over a language such as Smalltalk and the C integration brings
enormous foibles.

But that same C integration also brings enormous advantages. You can
directly call any C-based library on the system, which is essentially
all of them. You can drop in any portable C or C++ code you happen to
have, which is often a lot. ObjC by itself is nothing special, but
ObjC combined with the enormous amount of external code is extremely
powerful. This is the main reason why I continue to use ObjC for most
of my programming rather than switching to another language with a
Cocoa bridge.

> I never understood why Apple stopped supporting the Java bridge to Cocoa.

Too much work to maintain (Java's object model isn't really a good
match for ObjC, so the bridge was fairly unwieldy) and not enough
demand. Note that they've replaced it with bridges to languages which
are both better matches for the framework and which don't have their
own built-in GUI framework already. The Java bridge never excited me,
but having the OS ship with an officially supported Python bridge is
fantastic.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-07 Thread glenn andreas


On Jun 7, 2008, at 12:37 PM, Kevin Grant wrote:


It is possible to link your application through C to an
interpreter like Python or Perl, and rely on the built-in
regular expression libraries to do your work.  If you
really wanted to, you could fire off a call to /usr/bin/egrep.



That last one would possibly be the worse of all possible ways - the  
cost involves spanning another process (potentially for each regex),  
sending a potentially large string to it, parsing the output back from  
it to get any sort of results, made all the more complicated by the  
fact that there are all sorts of weird involved when sending non-ASCII  
to another process (since environment variables get involved to  
determine encoding schemes - and you have no way of knowing what the  
user set up in the hand full of default encoding environment  
parameters that exist).


NSTask works great for some things - shlepping large amount of string  
data back and forth for a simple utility isn't one of them.



These are all part of the default Mac OS X platform, they
require no dependency on a bundled framework, and have no
license issues.


Can't speak for Perl, but the Python framework changes from OS version  
to OS version, which can potentially cause problems with linking to  
it, so suddenly this introduces an OS dependency.  There is no  
"forward compatibility guarantee" that is implicit in various parts of  
AppKit (granted, there are occasionally problems there, but  those  
tend to be the except





In all honesty, you wouldn't want Apple to "implement" this
itself, because they'd have to start from scratch and there
would be bugs.  I listed 3 implementations that are very
mature and powerful.


Except that there already is a very good regex engine as part of the  
OS (ICU) which is used by some parts of the system already - it's just  
not fully exposed in Cocoa (so it's not like they'd be implementing it  
from scratch at all).  Asking that they take that last step seems like  
a very reasonable request (and it has been discussed for many-an-OS- 
release).





Glenn Andreas  [EMAIL PROTECTED]
  wicked fun!
m.o.t.e.s. | minute object twisted environment simulation



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-07 Thread Kevin Grant

It is possible to link your application through C to an
interpreter like Python or Perl, and rely on the built-in
regular expression libraries to do your work.  If you
really wanted to, you could fire off a call to /usr/bin/egrep.

These are all part of the default Mac OS X platform, they
require no dependency on a bundled framework, and have no
license issues.

In all honesty, you wouldn't want Apple to "implement" this
itself, because they'd have to start from scratch and there
would be bugs.  I listed 3 implementations that are very
mature and powerful.

The main downside in each case is that you're converting a
small amount of code and strings to the target form (command
line, Python or Perl code).

Kevin G.



As someone who has worked on a number of 3rd party [open source and
otherwise] frameworks, I wonder where this attitude comes from in  
the case

of Cocoa/Mac OS X. I have some ideas, but I hesitate to share them.


Four things:
1) There are certain basics like regex support that people are upset
at Apple for not implementing because it seems like such an important
part of the concept of strings.
2) Licensing issues can arise for third-party frameworks.
3) Objective-C has no namespaces, and categories are fragile.
4) Linking against a third-party framework requires distributing the
framework inside the app bundle.  Look at the proliferation of
Sparkle.framework to see why this is a Bad Thing(TM).

--Kyle Sluder

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-07 Thread Kyle Sluder
On Sat, Jun 7, 2008 at 10:43 AM, Jason Stephenson <[EMAIL PROTECTED]> wrote:
> As someone who has worked on a number of 3rd party [open source and
> otherwise] frameworks, I wonder where this attitude comes from in the case
> of Cocoa/Mac OS X. I have some ideas, but I hesitate to share them.

Four things:
1) There are certain basics like regex support that people are upset
at Apple for not implementing because it seems like such an important
part of the concept of strings.
2) Licensing issues can arise for third-party frameworks.
3) Objective-C has no namespaces, and categories are fragile.
4) Linking against a third-party framework requires distributing the
framework inside the app bundle.  Look at the proliferation of
Sparkle.framework to see why this is a Bad Thing(TM).

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-07 Thread John Engelhart


On Jun 6, 2008, at 1:27 PM, Vincent E. wrote:

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, \, …) 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


Actually, RegexKit handles perl like \u \l \U \L \E case conversions.

http://regexkit.sourceforge.net/Documentation/NSString.html#ExpansionofCaptureSubpatternMatchReferencesinStrings

example = [NSString stringWithUTF8String:"Stra\xc3\x9f" "e"]; // Straße
upper = [example stringByMatching:@"(.*)" replace:RKReplaceAll  
withReferenceString:@"\\U$1\\E"]; // STRASSE
lower = [upper stringByMatching:@"(.*)" replace:RKReplaceAll  
withReferenceString:@"\\L$1\\E"]; // strasse != Straße


As the example shows, case conversion is Unicode aware as well (ß ->  
SS -> ss).  Your example would become:


[@"Some string to do work on" stringByMatching:@"\\b(.*?)"  
replace:RKReplaceAll withReferenceString:@"\\u\\L$1"];


The replace:RKReplaceAll is the functional equivalent of the /g  
modifier.___


Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-07 Thread Ken Ferry
In math, a result is 'elegant' if it just _does_ something, simply and
quickly, rather than relying on a mass of machinery done elsewhere,
that you either have to assume works or spend time understanding.  A
large dependency can make it harder to say what, exactly, are the key
lynchpins that make the result happen.

I think code is similar.  Fewer dependencies is simpler, more elegant.
 Dropping in a chunk of code from elsewhere is not a huge deal.  A
class, a bit more so, a framework, more so, a framework with new
overarching patterns or a new language, more so, etc.

This goes further than 1st party vs 3rd party.  You'll see people want
to write in 'pure cocoa' or 'pure cocoa bindings'.

The tradeoff is that when Cocoa (or whatever) _doesn't_ do something
particularly well, using something else can easily make your code
enough simpler that it offsets the complexity of using the new thing.

But I think it's perfectly reasonable to use the new thing and then
grouse about how Apple should make it unnecessary. :-)

-Ken

On Sat, Jun 7, 2008 at 7:43 AM, Jason Stephenson <[EMAIL PROTECTED]> wrote:
> Ilan Volow wrote:
>>
>>  Back in the
>> Jaguar-era when I had to write applications that made heavy use of XML and
>> regular expressions, Cocoa-Java saved the day--no 3rd-party nonsense
>> required.
>
> This in not a knock on Ilan. His mail just happens to embody an attitude
> that I see quite frequently on this list, and I just feel that I have to
> share my puzzlement at this negative attitude toward 3rd party frameworks.
>
> It seems that many on this list feel that Apple should provide everything
> that the programmer needs to work on Mac OS X and that there should not be
> 3rd party frameworks for much of anything.
>
> This attitude really, truly puzzles me because on every other platform where
> I've programmed this attitude never came up in the discussion forums. It was
> always just assumed that you would need to use 3rd party frameworks to get
> any real work done, unless you intended to roll everything yourself.
>
> If you look at programming for Linux or any of the BSDs, you will definitely
> need to install frameworks from 3rd parties to do any GUI programming at
> all, or really any programming. After all, gcc is not produced by any of the
> major distributors or developers of Linux or BSD. Heck, even on the Mac,
> most of the programming frameworks are based on 3rd party frameworks
> underneath.
>
> The same is true for Perl where many applications have a list of 3rd party
> module dependencies that make Amy Winehouse look clean and sober. ;)
>
> The only other environment where I've programmed that this same attitude may
> rear its head could be Java land, but even there that attitude does not seem
> to rear its head quite so often as it seems to on this list.
>
> As someone who has worked on a number of 3rd party [open source and
> otherwise] frameworks, I wonder where this attitude comes from in the case
> of Cocoa/Mac OS X. I have some ideas, but I hesitate to share them.
>
> Puzzled,
> Jason
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-07 Thread Jason Stephenson

Ilan Volow wrote:

 Back in the
Jaguar-era when I had to write applications that made heavy use of XML 
and regular expressions, Cocoa-Java saved the day--no 3rd-party nonsense 
required.


This in not a knock on Ilan. His mail just happens to embody an attitude 
that I see quite frequently on this list, and I just feel that I have to 
share my puzzlement at this negative attitude toward 3rd party frameworks.


It seems that many on this list feel that Apple should provide 
everything that the programmer needs to work on Mac OS X and that there 
should not be 3rd party frameworks for much of anything.


This attitude really, truly puzzles me because on every other platform 
where I've programmed this attitude never came up in the discussion 
forums. It was always just assumed that you would need to use 3rd party 
frameworks to get any real work done, unless you intended to roll 
everything yourself.


If you look at programming for Linux or any of the BSDs, you will 
definitely need to install frameworks from 3rd parties to do any GUI 
programming at all, or really any programming. After all, gcc is not 
produced by any of the major distributors or developers of Linux or BSD. 
Heck, even on the Mac, most of the programming frameworks are based on 
3rd party frameworks underneath.


The same is true for Perl where many applications have a list of 3rd 
party module dependencies that make Amy Winehouse look clean and sober. ;)


The only other environment where I've programmed that this same attitude 
may rear its head could be Java land, but even there that attitude does 
not seem to rear its head quite so often as it seems to on this list.


As someone who has worked on a number of 3rd party [open source and 
otherwise] frameworks, I wonder where this attitude comes from in the 
case of Cocoa/Mac OS X. I have some ideas, but I hesitate to share them.


Puzzled,
Jason
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread Jose Raul Capablanca

Allison Newman said:

It's just that I can't help thinking about all of the comments that  
we see on this list from people coming from Java or some other  
language where header files aren't necessary, or which don't have  
pointers.  They are confused by these things, and having to learn  
that at the same time as learning Cocoa itself makes for a very  
steep learning curve.


Indeed.

I was one of the Java people you referred to. Nowadays, my day-time  
job is game programming in C and I dabble on Objective-C/Cocoa when  
time permits, so I think I've now gotten used to header files and  
pointers. But those things still feel to me as nothing more than  
fossils.


I know that Obj-C is more dynamic than Java (and that's quite  
important for Cocoa to work its magic), but if Apple had never  
developed Cocoa and were to do it now, from scratch, I doubt that they  
would choose to do it in a language that sits atop of C. With the  
exception of the id and SEL types, categories, and the fact that you  
can send messages to nil, I can't think of anything in Obj-C that  
isn't done better in Java, with the added benefits that Java has no  
header files, no include cycles, no pointers, and has automatic memory  
management that works (judging from another thread in this list,  
garbage collection in Obj-C 2.0 has some wrinkles).


I wonder how much more productive Cocoa programmers are in a parallel  
universe where Cocoa's native language is Java, with some extensions  
added to the language to support the extra features mentioned above.


I never understood why Apple stopped supporting the Java bridge to  
Cocoa.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread David Troy
Syntactical transformations, especially those where semantic parity is  
retained, have never struck me as much of a barrier.


I am new to Objective C (though not to C) and have had a lot of  
experience in Ruby, and I am struck by how structurally similar  
Objective C and Ruby actually are.  The semantic constructs I've  
developed over the years for Ruby apply quite nicely in ObjC, and I  
can see why there was a temptation to develop Ruby Cocoa.


Anyway, I think some of us are arguing that Cocoa is a semantic  
framework, while others are arguing it's a syntactic + semantic  
framework, and I don't really agree.  As long as you're able to think  
about the frameworks in a purely semantic manner, (which honestly  
requires literacy in multiple syntaxes) then you can code in whatever  
language makes you happy.


That all said, getting to a point where you think about programming in  
mostly semantic terms takes some experience.


Dave


On Jun 7, 2008, at 8:52 AM, Hamish Allan wrote:

On Sat, Jun 7, 2008 at 8:20 AM, Allison Newman <[EMAIL PROTECTED]>  
wrote:



Really, once you figure out how to translate

obj = [[SomeClass alloc] initWithName: @'my name' size: 16]

to

obj = SomeClass.alloc.initWithName_size('my name', 16)

you're ready to start programming with RubyCocoa (assuming of  
course that you know already how to program in ruby).


Perhaps what John meant was that once you've figured out what the
translation actually means, you've basically already learned
Objective-C (if you already know C).

Hamish
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/dave%40popvox.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread Hamish Allan
On Sat, Jun 7, 2008 at 8:20 AM, Allison Newman <[EMAIL PROTECTED]> wrote:

> Really, once you figure out how to translate
>
> obj = [[SomeClass alloc] initWithName: @'my name' size: 16]
>
> to
>
> obj = SomeClass.alloc.initWithName_size('my name', 16)
>
> you're ready to start programming with RubyCocoa (assuming of course that you 
> know already how to program in ruby).

Perhaps what John meant was that once you've figured out what the
translation actually means, you've basically already learned
Objective-C (if you already know C).

Hamish
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread Felipe Monteiro de Carvalho
On Sat, Jun 7, 2008 at 4:20 AM, Allison Newman <[EMAIL PROTECTED]> wrote:
> obj = [[SomeClass alloc] initWithName: @'my name' size: 16]
>
> to
>
> obj = SomeClass.alloc.initWithName_size('my name', 16)

And in Pascal:

obj := SomeClass.initWithName_size('my name', 16);

(alloc is called automatically)

-- 
Felipe Monteiro de Carvalho
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-07 Thread Ilan Volow
What I found so useful about Cocoa-Java was that it was the perfect  
tool for easily writing Cocoa Apps that made heavy use of technologies  
that Apple was too short-sighted to add, largely because Java came out- 
of-the-box with so many useful classes for basic stuff like regular  
expressions. And its integration with the rest of the environment made  
it far less painful than the other language bindings. Back in the  
Jaguar-era when I had to write applications that made heavy use of XML  
and regular expressions, Cocoa-Java saved the day--no 3rd-party  
nonsense required.


Those were the days...

-- Ilan

On Jun 6, 2008, at 5:47 PM, Stephen J. Butler wrote:

On Fri, Jun 6, 2008 at 10:13 AM, glenn andreas <[EMAIL PROTECTED]>  
wrote:

One other possible solution is to use the JavaScriptCore and make a
JSStringRef (which works with unichars like NSString), and use  
JavaScript's
regex support - that way the results will at least have consistent  
indices,

work well with non-ASCII characters, etc...


As long as we're discussing really far out solutions...

There's the Java java.util.regex package. One could write some JNI and
wrap the Java package (only two classes) although you'd have to start
up the VM.

Personally, I like some of the extensions that Java adds to the  
patterns.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/listboy%40clarux.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread Allison Newman
I can't for the life of me imagine why you would think that.  I mean, I'm not 
theorising here, I have actually done it.  My very first Cocoa app was a 
RubyCocoa app, and my second, a true, full-featured app, is just about done.  
And you know what, I never did regret my decision to not really learn Objective 
C.

Now, of course, I can readily believe that one of these days I'm going to want 
to do something a bit more processor intensive, or which needs a better 
threading architecture than that provided by Ruby.  But you know what? When 
that day comes, I'll learn Objective-C.  But what's great about the way that I 
did it was that I will already know Cocoa at that point.  I'll know how undos 
work, I'll know how to use delegates and data sources, I'll know how Apple has 
implemented the MVC pattern, and all of this will make learning the bits of 
Objective C that I am currently blissfully unaware of a very simple task.

Really, once you figure out how to translate

obj = [[SomeClass alloc] initWithName: @'my name' size: 16]

to

obj = SomeClass.alloc.initWithName_size('my name', 16)

you're ready to start programming with RubyCocoa (assuming of course that you 
know already how to program in ruby).  As an added bonus, if you're typing on a 
French keyboard, you have less [ and ]'s to type, which is a blessing because 
the damn things are three-key combos! :-)

Anyway, I think I'll stop spamming the list with RubyCocoa advocacy now.  It's 
just that I can't help thinking about all of the comments that we see on this 
list from people coming from Java or some other language where header files 
aren't necessary, or which don't have pointers.  They are confused by these 
things, and having to learn that at the same time as learning Cocoa itself 
makes for a very steep learning curve.  The RubyCocoa or PyObjC bridges make it 
possible to reduce the steepness of the curve.

> Le 7 juin 08 à 04:54, [EMAIL PROTECTED] a écrit :
>
> On Jun 6, 2008, at 2:10 AM, Allison Newman wrote:
> 
>> you don't have to fully learn Objective C's syntax at the same time
>> as Cocoa.
> 
> Ok, all kinds of alarm bells just went off.   Obj-C is a very small
delta from C, and if you avoid learning it, you will regret it.
> 
> -jcr


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread John C. Randolph


On Jun 6, 2008, at 2:10 AM, Allison Newman wrote:

 you don't have to fully learn Objective C's syntax at the same time  
as Cocoa.


Ok, all kinds of alarm bells just went off.   Obj-C is a very small  
delta from C, and if you avoid learning it, you will regret it.


-jcr
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Stephen J. Butler
On Fri, Jun 6, 2008 at 10:13 AM, glenn andreas <[EMAIL PROTECTED]> wrote:
> One other possible solution is to use the JavaScriptCore and make a
> JSStringRef (which works with unichars like NSString), and use JavaScript's
> regex support - that way the results will at least have consistent indices,
> work well with non-ASCII characters, etc...

As long as we're discussing really far out solutions...

There's the Java java.util.regex package. One could write some JNI and
wrap the Java package (only two classes) although you'd have to start
up the VM.

Personally, I like some of the extensions that Java adds to the patterns.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Jens Alfke


On 6 Jun '08, at 8:13 AM, glenn andreas wrote:

One other possible solution is to use the JavaScriptCore and make a  
JSStringRef (which works with unichars like NSString), and use  
JavaScript's regex support - that way the results will at least have  
consistent indices, work well with non-ASCII characters, etc...


JavaScriptCore is just using PCRE*. That basically supports Unicode,  
but I have had problems in the past with non-Roman text in JS regular  
expressions (particularly with word breaks in Japanese text). I think  
ICU is a better bet.


—Jens

* and until a month or two ago it was a very ancient version of PCRE,  
with prominent security holes; that's how that guy won a MacBook Pro  
in the "Pwn2Own" contest.

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Regular Expressions?

2008-06-06 Thread James Montgomerie

On 6 Jun 2008, at 08:03, Jens Alfke wrote:


On 6 Jun '08, at 3:23 AM, Jason Stephenson wrote:

As a long time UNIX programmer, I'll suggest looking into the  
regexp library that already comes with OS X.

man regcomp on the command line to find out how to use.


It doesn't look as though this library is Unicode-aware. The strings  
it takes are C string (char*) with no indication of what encoding is  
used, and Unicode or UTF-8 aren't mentioned in the man page. From  
that, I'd guess that this library only works with single-byte  
encodings (like ISO-Latin-1 or CP-1252, not UTF-8 or the various non- 
Roman encodings) and that it will treat all non-ascii characters as  
being not spaces and not letters.


In short, I think it only works correctly with plain ascii. IMHO  
that's much too limited for most purposes nowadays. Even if you  
don't touch user-visible text with it, it's still pretty common to  
find non-ascii characters in HTML, XML, even source code.


Of the regex libraries mentioned so far, I recommend RegexKitLite.  
It's based on ICU, which is Unicode-savvy, already built into the  
OS, and used by lots of Apple apps.


You are correct, but in my casual usage, feeding UTF-8 to the POSIX  
regex routines works just fine if you take into account that the  
defined character classes are ASCII-aware only, and are aware that the  
results you get back are byte offsets, not character offsets - i.e.  
don't convert them to NSRanges and expect them to be correct against  
the NSString you got the UTF-8 from (similar caveats apply to match  
counts etc. - i.e. ".{3}" will happily match two characters if they  
take up three bytes).


I wouldn't want to present the regexes to the user, of course, but for  
pre-defined regexes in code, it's okay (not great with those caveats  
obviously, but alright).


My main complaint about it is that it's /extremely slow/ compared to  
most modern regex libraries, but for casual usage, you at least don't  
have to link any extra libraries to use it.


I do think that good regex additions to NSString, or an NSRegex class,  
are highly overdue in Cocoa.


Jamie.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Vincent E.
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, \, …) 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-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread David Hoerl

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 ?



Well, Terry Jones wrote a routine called "strsed" in 1990 that in 
fact does this:


http://www.jones.tc/personal/odds-and-ends.html

It was loosely modeled on sed(1). It's a C routine that has this format:

str = strsed(string, command, option);

The strings is something like "Hello world". The command is of the form:

s/search/replace/ or g/search/replace/

The "s" version finds the first match and replaces it. The "g" 
version finds and replaces every occurrence. It uses the regex(3) 
library.


That's the good part. The bad part is that uses the older simpler 
regex capability. I'm in the process of modernizing this code to use 
the POSIX mode of regex(3), and hope to have it done next week. I 
will eventually put it on my not-yet-done web site and support it 
(maybe a small ObjC class for use with the icu library too).


In the mean time, email me if you want version 1 (couple of days). It 
will be released with a very permissive license as the base code was 
totally open source.


David
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread dream cat7

... pcre takes utf8 strings
... utf-16 is supported by RegexKitLite & lib ICU

... NSString and CFString are implemented as utf-16

On 6 Jun 2008, at 16:02, Jason Stephenson wrote:

Replying to myself here, which I know is generally a bad thing, but  
this thought just came to me.


I have yet to find a regex library that handles UTF-16 well, if at  
all. I actually spent a couple of hours yesterday trying to mangle  
some UTF-16 files in Perl using regular expressions. I gave up and  
did it in Emacs, the only environment where I've seen REs handle  
UTF16 properly.


So, that's now my mission, to come up with a RE library that handles  
UTF16 as gracefully as 7 bit ASCII.


Cheers,
Jason
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/dreamcat7%40googlemail.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Jens Alfke


On 6 Jun '08, at 8:02 AM, Jason Stephenson wrote:

I have yet to find a regex library that handles UTF-16 well, if at  
all. I actually spent a couple of hours yesterday trying to mangle  
some UTF-16 files in Perl using regular expressions. I gave up and  
did it in Emacs, the only environment where I've seen REs handle  
UTF16 properly.


ICU is entirely UTF-16 based.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Regular Expressions?

2008-06-06 Thread Jason Stephenson

glenn andreas wrote:

[wrote about how using regex is not a good idea, particularly with 
NSString and unicode. Pretty much the same things that Jens wrote earlier.]


Yes, that's all very true. Regex is a poor choice if you're working on 
non-ASCII text. I'm generally not doing so, but just yesterday did have 
the unpleasant experience of regexing some UTF16 files. (See another 
email by me in this thread.)


You could kludge it to work using some options that are available on Mac 
OS X and FreeBSD regex libraries. (Don't know if it is available 
elsewhere, but likely is.) Essentially, you tell regcomp to ignore nuls 
and then you have a lot of fun coding REs that match your UTF16 strings 
taking into account endianness and all. I've pondered how it would work 
and am confident that it would work, but also concede that it would be a 
very ugly hack and be prone to breakage.


One other possible solution is to use the JavaScriptCore and make a 
JSStringRef (which works with unichars like NSString), and use 
JavaScript's regex support - that way the results will at least have 
consistent indices, work well with non-ASCII characters, etc...


That is an excellent option if you're using JavaScriptCore already, or 
maybe even if you're not. There's another thing to look into. Anyone for 
a unicode text editor that is scriptable in JavaScript? (Hmm, maybe the 
world really doesn't need another text editor.) :P


For now, I'm going to look into ICU. I seem to have a couple of copies 
of it on my computer.


Cheers,
Jason
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread glenn andreas


On Jun 6, 2008, at 5:23 AM, Jason Stephenson wrote:


Hi,

You've gotten a lot of decent answers so far.

As a long time UNIX programmer, I'll suggest looking into the regexp  
library that already comes with OS X.


man regcomp on the command line to find out how to use.


Note that NSStrings are usually internally stored as UTF-16, and  
regcomp requires a "char *", so at the very least, you'll need to  
convert the NSString to UTF-8, which can be expensive (in terms of  
having to make a large copy of a potentially very large string and  
walk through before doing any regex work on it).


Worse, once converted to UTF8, it's not documented that regcomp works  
correctly for any UTF-8 other than ASCII.


Even worse, converting from an index in a UTF-8 string back to the  
corresponding index in the original NSString is also problematic - you  
basically have to walk through the UTF-8 string, counting code points  
(which count double for surrogate pairs).


As a result, using regcomp works OK for shorter strings that are pure  
ASCII to start with, but longer string or non-ASCII characters start  
to increase the problem...



One other possible solution is to use the JavaScriptCore and make a  
JSStringRef (which works with unichars like NSString), and use  
JavaScript's regex support - that way the results will at least have  
consistent indices, work well with non-ASCII characters, etc...



Glenn Andreas  [EMAIL PROTECTED]
  wicked fun!
JSKit | the easy way to unite JavaScript and Objective C



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Jens Alfke


On 6 Jun '08, at 3:23 AM, Jason Stephenson wrote:

As a long time UNIX programmer, I'll suggest looking into the regexp  
library that already comes with OS X.

man regcomp on the command line to find out how to use.


It doesn't look as though this library is Unicode-aware. The strings  
it takes are C string (char*) with no indication of what encoding is  
used, and Unicode or UTF-8 aren't mentioned in the man page. From  
that, I'd guess that this library only works with single-byte  
encodings (like ISO-Latin-1 or CP-1252, not UTF-8 or the various non- 
Roman encodings) and that it will treat all non-ascii characters as  
being not spaces and not letters.


In short, I think it only works correctly with plain ascii. IMHO  
that's much too limited for most purposes nowadays. Even if you don't  
touch user-visible text with it, it's still pretty common to find non- 
ascii characters in HTML, XML, even source code.


Of the regex libraries mentioned so far, I recommend RegexKitLite.  
It's based on ICU, which is Unicode-savvy, already built into the OS,  
and used by lots of Apple apps.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Regular Expressions?

2008-06-06 Thread Jason Stephenson
Replying to myself here, which I know is generally a bad thing, but this 
thought just came to me.


I have yet to find a regex library that handles UTF-16 well, if at all. 
I actually spent a couple of hours yesterday trying to mangle some 
UTF-16 files in Perl using regular expressions. I gave up and did it in 
Emacs, the only environment where I've seen REs handle UTF16 properly.


So, that's now my mission, to come up with a RE library that handles 
UTF16 as gracefully as 7 bit ASCII.


Cheers,
Jason
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Jason Stephenson

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 ?


Would something like this be acceptable?

[someString replacePattern: @"\\b(.*?)" with: @"\\u\\L$1" flags: @"g"];

It is pretty much how I have considered handling substitions in the 
category that I'm designing.


As for string subs in C libraries, I really am only familiar with using 
the POSIX standard regex library. You can do that sort of thing in it, 
but it is not as simple as writing a single line of code.


I have some limited experience with PCRE, and IIRC the coding is more 
less the same there.


I don't know of any regex library that will accept s in a string. 
That's a bit of syntactic sugar that makes Perl so sweet. ;)


Cheers,
Jason
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread dream cat7


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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Dave DeLong
I've used OgreKit before and found it's worked pretty well.

http://www8.ocn.ne.jp/%7esonoisa/OgreKit/index.html

Dave

On Fri, Jun 6, 2008 at 1:31 AM, Cemil Browne <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> This might be a really silly question - but am I missing something obvious?
>  Is there any support at all for regular expressions in the Cocoa libraries?
>
> I can't find anything and I've found some third-party frameworks - but
> surely something so necessary must be buried in the string classes
> somewhere? How would I do a simple substring search or replace in 10.4?
>
> Thanks,
> Cemil
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Vincent E.
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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread dream cat7


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, ...;




On 6 Jun 2008, at 11:01, Vincent E. wrote:


But RegexKitLite does not support substitution, does it?
Regex pattern matching is one thing, regex string substitution  
another.


On Jun 6, 2008, at 11:34 AM, dream cat7 wrote:



Perhaps also consider RegexKitLite, which is written by the same  
author. The difference is it links to shared libicu thats already  
distributed in the os. No need to embed some specific version of  
PCRE library into your app included with the regexkit (saves ~1.6mb  
in the bundle). Also the icu library is something apple uses (and  
unlikely to go away in future releases of OS X).



On 6 Jun 2008, at 09:22, Cemil Browne wrote:


Thanks to everyone who replied - I appreciate the help.

The best solution I've found (and been told) is to use a third  
party Regex

library - http://regexkit.sourceforge.net/  appears to be decent.

NSScanner does not really appear to do what I'm looking for - but  
is useful

to know about regardless.

Thanks all,

-Cemil

On Fri, Jun 6, 2008 at 6:11 PM, Citizen <[EMAIL PROTECTED]>  
wrote:


If you are not married to using regular expressions, NSScanner  
can do much
the same in a more verbose (generally easier to read) way. I only  
mention

this because it is often overlooked.


On 6 Jun 2008, at 08:31, Cemil Browne wrote:

Hi all,


This might be a really silly question - but am I missing something
obvious?
Is there any support at all for regular expressions in the Cocoa
libraries?

I can't find anything and I've found some third-party frameworks  
- but

surely something so necessary must be buried in the string classes
somewhere? How would I do a simple substring search or replace  
in 10.4?


Thanks,
Cemil
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/citizen%40zenopolis.com

This email sent to [EMAIL PROTECTED]




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:

http://lists.apple.com/mailman/options/cocoa-dev/cemilb%2Bcocoadev%40gmail.com

This email sent to [EMAIL PROTECTED] <[EMAIL PROTECTED] 
>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/dreamcat7%40googlemail.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/mailinglists%40satsumac.com

This email sent to [EMAIL PROTECTED]




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Jason Stephenson

Hi,

You've gotten a lot of decent answers so far.

As a long time UNIX programmer, I'll suggest looking into the regexp 
library that already comes with OS X.


man regcomp on the command line to find out how to use.

I've used it for years in my C applications on UNIX and UNIX-like 
operating systems. I've even made some simple classes for using the lib 
in Cocoa. Admittedly the interface is a bit schizoid, but I'll email it 
to you if you're interested in looking at it.


I've looked at RegexKit and it looks good if you want Perl compatible 
regular expressions. The license isn't bad, so you can add it to your 
application without doing much, though giving a plug to the author(s) in 
your About panel would be nice. ;)


I'll have to add making a nice interface for the system regex library to 
my list of things to do. Maybe I'll get to that this weekend right after 
doing bas64, UUcode, binHex, etc. ;)


Cheers,
Jason

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Vincent E.

But RegexKitLite does not support substitution, does it?
Regex pattern matching is one thing, regex string substitution another.

On Jun 6, 2008, at 11:34 AM, dream cat7 wrote:



Perhaps also consider RegexKitLite, which is written by the same  
author. The difference is it links to shared libicu thats already  
distributed in the os. No need to embed some specific version of  
PCRE library into your app included with the regexkit (saves ~1.6mb  
in the bundle). Also the icu library is something apple uses (and  
unlikely to go away in future releases of OS X).



On 6 Jun 2008, at 09:22, Cemil Browne wrote:


Thanks to everyone who replied - I appreciate the help.

The best solution I've found (and been told) is to use a third  
party Regex

library - http://regexkit.sourceforge.net/  appears to be decent.

NSScanner does not really appear to do what I'm looking for - but  
is useful

to know about regardless.

Thanks all,

-Cemil

On Fri, Jun 6, 2008 at 6:11 PM, Citizen <[EMAIL PROTECTED]>  
wrote:


If you are not married to using regular expressions, NSScanner can  
do much
the same in a more verbose (generally easier to read) way. I only  
mention

this because it is often overlooked.


On 6 Jun 2008, at 08:31, Cemil Browne wrote:

Hi all,


This might be a really silly question - but am I missing something
obvious?
Is there any support at all for regular expressions in the Cocoa
libraries?

I can't find anything and I've found some third-party frameworks  
- but

surely something so necessary must be buried in the string classes
somewhere? How would I do a simple substring search or replace in  
10.4?


Thanks,
Cemil
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/citizen%40zenopolis.com

This email sent to [EMAIL PROTECTED]




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:

http://lists.apple.com/mailman/options/cocoa-dev/cemilb%2Bcocoadev%40gmail.com

This email sent to [EMAIL PROTECTED] <[EMAIL PROTECTED] 
>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/dreamcat7%40googlemail.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/mailinglists%40satsumac.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread dream cat7


Perhaps also consider RegexKitLite, which is written by the same  
author. The difference is it links to shared libicu thats already  
distributed in the os. No need to embed some specific version of PCRE  
library into your app included with the regexkit (saves ~1.6mb in the  
bundle). Also the icu library is something apple uses (and unlikely to  
go away in future releases of OS X).



On 6 Jun 2008, at 09:22, Cemil Browne wrote:


Thanks to everyone who replied - I appreciate the help.

The best solution I've found (and been told) is to use a third party  
Regex

library - http://regexkit.sourceforge.net/  appears to be decent.

NSScanner does not really appear to do what I'm looking for - but is  
useful

to know about regardless.

Thanks all,

-Cemil

On Fri, Jun 6, 2008 at 6:11 PM, Citizen <[EMAIL PROTECTED]> wrote:

If you are not married to using regular expressions, NSScanner can  
do much
the same in a more verbose (generally easier to read) way. I only  
mention

this because it is often overlooked.


On 6 Jun 2008, at 08:31, Cemil Browne wrote:

Hi all,


This might be a really silly question - but am I missing something
obvious?
Is there any support at all for regular expressions in the Cocoa
libraries?

I can't find anything and I've found some third-party frameworks -  
but

surely something so necessary must be buried in the string classes
somewhere? How would I do a simple substring search or replace in  
10.4?


Thanks,
Cemil
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/citizen%40zenopolis.com

This email sent to [EMAIL PROTECTED]




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:

http://lists.apple.com/mailman/options/cocoa-dev/cemilb%2Bcocoadev%40gmail.com

This email sent to [EMAIL PROTECTED] <[EMAIL PROTECTED] 
>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/dreamcat7%40googlemail.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Allison Newman
 
On Friday, June 06, 2008, at 10:24AM, <[EMAIL PROTECTED]> wrote:
>As big of a fan as I am of both RubyCocoa and PyObjC, I would never  
>recommend either of them for use by someone relatively new to Cocoa  
>(of which it sounds like the OP might be).
>
>Even with the awesome quality of the bridges -- and RubyCocoa / PyObjC  
>are not the only ones -- there is still too much of an impedance  
>mismatch between the two running environments for it to be considered  
>easy to use.A far more productive approach is to reduce the number  
>of variables by gaining confidence / competence in pure Objective-C  
>based Cocoa, then adding whatever scripting language you are familiar  
>with into the mix after.
>
>b.bum

As someone that is actually doing precisely that (learning Cocoa by using 
RubyCocoa), I'd have to disagree.  The 'impedence mismatch' is really quite 
small (so far, I have only hit one nasty case), and it means that you don't 
have to fully learn Objective C's syntax at the same time as Cocoa. Obviously 
you do have to learn enough ObjC syntax to be able to read the documentation, 
but that's a far easier task than learning to write ObjC code (and I say that 
as someone that writes pure C code for a day-job).

Anyway, I guess it comes down to personal preferences.  But I don't think the 
problems of the scripting bridges are significant enough to justify a blanket 
'don't do this if you're a beginner'.

Alli 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Hamish Allan
On Fri, Jun 6, 2008 at 8:31 AM, Cemil Browne <[EMAIL PROTECTED]> wrote:

> This might be a really silly question - but am I missing something obvious?
>  Is there any support at all for regular expressions in the Cocoa libraries?

You can use NSPredicate for regexp matching, though no substitution is possible:

NSPredicate *pred = [NSPredicate predicateWithFormat:@"self matches
%@", yourRegexp];
BOOL result = [pred evaluateWithObject:yourString];

Hamish
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Cemil Browne
Thanks to everyone who replied - I appreciate the help.

The best solution I've found (and been told) is to use a third party Regex
library - http://regexkit.sourceforge.net/  appears to be decent.

NSScanner does not really appear to do what I'm looking for - but is useful
to know about regardless.

Thanks all,

-Cemil

On Fri, Jun 6, 2008 at 6:11 PM, Citizen <[EMAIL PROTECTED]> wrote:

> If you are not married to using regular expressions, NSScanner can do much
> the same in a more verbose (generally easier to read) way. I only mention
> this because it is often overlooked.
>
>
> On 6 Jun 2008, at 08:31, Cemil Browne wrote:
>
>  Hi all,
>>
>> This might be a really silly question - but am I missing something
>> obvious?
>> Is there any support at all for regular expressions in the Cocoa
>> libraries?
>>
>> I can't find anything and I've found some third-party frameworks - but
>> surely something so necessary must be buried in the string classes
>> somewhere? How would I do a simple substring search or replace in 10.4?
>>
>> Thanks,
>> Cemil
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/citizen%40zenopolis.com
>>
>> This email sent to [EMAIL PROTECTED]
>>
>>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
>
> http://lists.apple.com/mailman/options/cocoa-dev/cemilb%2Bcocoadev%40gmail.com
>
> This email sent to [EMAIL PROTECTED] <[EMAIL PROTECTED]>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Citizen
If you are not married to using regular expressions, NSScanner can do  
much the same in a more verbose (generally easier to read) way. I only  
mention this because it is often overlooked.


On 6 Jun 2008, at 08:31, Cemil Browne wrote:


Hi all,

This might be a really silly question - but am I missing something  
obvious?
Is there any support at all for regular expressions in the Cocoa  
libraries?


I can't find anything and I've found some third-party frameworks - but
surely something so necessary must be buried in the string classes
somewhere? How would I do a simple substring search or replace in  
10.4?


Thanks,
Cemil
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/citizen%40zenopolis.com

This email sent to [EMAIL PROTECTED]




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Bill Bumgarner

On Jun 6, 2008, at 1:01 AM, David Troy wrote:

Depending on what you're doing you could try using Ruby Cocoa.

In theory this should give you access to all of Ruby's internal  
regexp support, combined with the GUI goodness of Cocoa.  However,  
this has limitations of its own, such as distribution audience,  
speed, etc.


As big of a fan as I am of both RubyCocoa and PyObjC, I would never  
recommend either of them for use by someone relatively new to Cocoa  
(of which it sounds like the OP might be).


Even with the awesome quality of the bridges -- and RubyCocoa / PyObjC  
are not the only ones -- there is still too much of an impedance  
mismatch between the two running environments for it to be considered  
easy to use.A far more productive approach is to reduce the number  
of variables by gaining confidence / competence in pure Objective-C  
based Cocoa, then adding whatever scripting language you are familiar  
with into the mix after.


b.bum
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Bob Warwick

Hello -

Whoops!  I can read.

	You use the replaceOccurrencesOfString:withString:options:range:  
method in NSMutableString.  It works on the same instance of the  
string instead of creating a new string.


For example:

	NSMutableString *someString = [NSMutableString stringWithString:@"The  
quick brown fox"];
	[someString replaceOccurrencesOfString:@"quick" withString:@"slow"  
options:NSCaseInsensitiveSearch range:NSMakeRange(0, [someString  
length])];


-Bob Warwick
[EMAIL PROTECTED]

On 6-Jun-08, at 4:54 AM, Cemil Browne wrote:


Bob,

Thanks for the reply...

However, stringByReplacingOccurrencesOfString only works in Tiger,  
though, right?  What did everyone do last year for it?


-Cemil
On 06/06/2008, at 5:51 PM, Bob Warwick wrote:


Hello -

	There is no regular expression support in Cocoa.  You might find http://www.cocoadev.com/index.pl?RegularExpressions 
 useful in helping to find a library to do it for you.


Search and replace in Cocoa looks like this:

NSString *someString = @"The quick brown fox";
	NSString *newString = [someString  
stringByReplacingOccurrencesOfString:@"quick" withString:@"slow"];


	You can find this in the NSString documentation.  It creates a new  
string with the substring replaced.


-Bob Warwick
[EMAIL PROTECTED]

On 6-Jun-08, at 4:31 AM, Cemil Browne wrote:


Hi all,

This might be a really silly question - but am I missing something  
obvious?
Is there any support at all for regular expressions in the Cocoa  
libraries?


I can't find anything and I've found some third-party frameworks -  
but

surely something so necessary must be buried in the string classes
somewhere? How would I do a simple substring search or replace in  
10.4?


Thanks,
Cemil
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/warwick%40codehackers.net

This email sent to [EMAIL PROTECTED]






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread David Troy

Depending on what you're doing you could try using Ruby Cocoa.

In theory this should give you access to all of Ruby's internal regexp  
support, combined with the GUI goodness of Cocoa.  However, this has  
limitations of its own, such as distribution audience, speed, etc.


Dave



On Jun 6, 2008, at 3:55 AM, Bob Warwick wrote:


On 6-Jun-08, at 4:31 AM, Cemil Browne wrote:


Hi all,

This might be a really silly question - but am I missing something  
obvious?
Is there any support at all for regular expressions in the Cocoa  
libraries?


I can't find anything and I've found some third-party frameworks -  
but

surely something so necessary must be buried in the string classes
somewhere? How would I do a simple substring search or replace in  
10.4?


Thanks,
Cemil



Hello -

	There is no regular expression support in Cocoa.  You might find http://www.cocoadev.com/index.pl?RegularExpressions 
 useful in helping to find a library to do it for you.


Search and replace in Cocoa looks like this:

NSString *someString = @"The quick brown fox";
	NSString *newString = [someString  
stringByReplacingOccurrencesOfString:@"quick" withString:@"slow"];


	You can find this in the NSString documentation.  It creates a new  
string with the substring replaced.


-Bob Warwick
[EMAIL PROTECTED]
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/dave%40popvox.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


  1   2   >