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
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
