Re: need help for regular expression
- From: Li Chen <chen_li3@xxxxxxxxx>
- Date: Wed, 2 Jul 2008 18:17:46 -0500
Chris Shea wrote:
On Jul 2, 3:46?pm, Li Chen <chen_...@xxxxxxxxx> wrote:
--
Posted viahttp://www.ruby-forum.com/.
Li,
Well, there are few different ways.
string.sub!(/\(.*?\)/,'')
string.sub!(/\([^)]*\)/,'')
If there's a chance that there will be nested parentheses, you'll need
something more complicated.
It seems like you're often asking regular expression questions. I'd
highly recommend picking up Mastering Regular Expressions by Jeffrey
Friedl. After reading just the first two chapters, you'll be able to
figure stuff like this out very easily. After reading a few more
chapters, you'll know the difference between the two expressions above
and which one you want to use.
HTH,
Chris
Hi Chris,
Thank you very much. I will take a look at "Mastering Regular
Expressions".
Li
--
Posted via http://www.ruby-forum.com/.
.
- References:
- need help for regular expression
- From: Li Chen
- Re: need help for regular expression
- From: Chris Shea
- need help for regular expression
- Prev by Date: Re: Threads and Ruby
- Next by Date: Re: Missing zlib on latest ruby version
- Previous by thread: Re: need help for regular expression
- Next by thread: Lost with OptionParser
- Index(es):
Relevant Pages
|