Re: need help for regular expression



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/.

.



Relevant Pages

  • Re: Data validation, mandatory and restricted field length for excel vbs
    ... Just so one reading this thread gets confused, ... Not quite a Regular Expression parser, yet it offers simple, and fairly readable, parsing syntax, something a Regular Expression statement cannot begin to claim. ... That second link takes you to the noted Excel author John Walkenbach's blog site; what I am particularly proud of with respect to my code posted there is the reaction John posted in this blog article in response to my offering it to him... ... Rick Rothstein ...
    (microsoft.public.excel.programming)
  • Re: IO function in Vb.Net slower than in Vb6.0
    ... returned does not contain the terminating carriage return or line feed. ... before you can apply the RegEx anyway. ... >> Can you please paste the regular expression for this? ... if it is changed to reading one ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How to get regexprep to exclude data between paranthesis
    ... Thanks a lot Jason, that was a very detailed answer. ... Matching nested parentheses requires ... character that are outside of nested groups. ... And here is the combined regular expression: ...
    (comp.soft-sys.matlab)
  • Re: IO function in Vb.Net slower than in Vb6.0
    ... if it is changed to reading one ... This is the Regular Expression: ... Search For RegEx or ... I'll try to "simulate"(wink wink:) a 400mb file and check performance. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Find files matching multiple patterns.
    ... You'd do well to do some more reading of ‘grep’. ... A regular expression can have alternation in it: ... when GNU grep can do it for you: ...
    (comp.unix.shell)