Thanks a million for the explanation Jeff I'd spent a long time before I'd figured that out.
 
Thanks,
Mark.
-----Original Message-----
From: Jeff Wood [mailto:[EMAIL PROTECTED]
Sent: 28 October 2005 16:02
To: [email protected]
Subject: Re: [Wtr-general] My regexp is too greedy!!

The part you are most likely having trouble with is the ?: at the beginning of the first group.
 
Starting a group with ?: tells the regex engine to NOT output that group into the matches collection.
 
j.
 
On 10/28/05, Jeff Wood <[EMAIL PROTECTED] > wrote:
The [^ ] example won't work if the the filenames are all mashed together:
 
file1.xml,file2.xml,file3_local.xml,file4.xml
 
Same for the \b example ...
 
\b means whitespace/non-whitespace boundary.
 
If you have whitespace, \b will hit when it stops ( and you start a word )
If you are in a word ( non-whitespace ) , \b will hit when it stops ( and you hit whitespace )
 
\b is really cool when you use it in split ...
 
j.

 
On 10/28/05, Mark Gargan <[EMAIL PROTECTED] > wrote:
Hi Bret,

       Hah! That is neat Bret. I couldn't get the second one to
work but the first one was sweet as a nut. I understand that the
[^ ] means any characters that's not a space but how does it know
to return the whole word involved?

I don't recall seeing \b in regexps before what does it mean?
Apologies for the newbiness.

Thanks,
Mark.


-----Original Message-----
From: Bret Pettichord [mailto:[EMAIL PROTECTED]]
Sent: 28 October 2005 05:47
To: [email protected]
Subject: Re: [Wtr-general] My regexp is too greedy!!


At 04:19 PM 10/27/2005, Jeff Wood wrote:
>/[a-zA-Z0-9\._]*local.xml/.match('xpl.xml, demoUK.xml,
>met_local.xml, cfg.xml')[0]
>
>should work. just add any chars that are allowed in names to the []
>portion of the regex, you should be all good.

Or use:
  /[^ ]*local.xml/
or
  /\blocal.xml/

_____________________
Bret Pettichord
www.pettichord.com

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general



--

" http://ruby-lang.org -- do you ruby?"

Jeff Wood



--
"http://ruby-lang.org -- do you ruby?"

Jeff Wood
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to