in reply to Text elimination within a string

s/^\(.*\)//;

As long as you are sure there will be no braces in the following text.

If text in braces is always in upper case, you could use:

s/^\([^a-z]+\)//;

to eliminate that possible problem.

cLive ;-)

Update: - added some hats to the regex (forgot them earlier...)

Replies are listed 'Best First'.
Re: Re: Text elimination within a string
by how do i know if the string is regular expression (Initiate) on Apr 08, 2001 at 17:48 UTC
    Though, if there is a chance that there would be parens in the later part of the string...

    (BW)(CA-LIGAND-PHARMACEUTICALS)(LGND) Ligand's Targretin Capsules Approved in Europe, Targretin Gel European Application Submitted; Ligand to Receive $3.5 Million (¥433.3 Million) Milestone Payments From Elan

    ... that regex would take out most of the wanted text.

    s/^(\(.*?\))*//;
    That will only take of the leading text encased in parens.

    - FrankG

      Add a g as option to your s/// and might be right. Still you should consider using the following regex that doesn't use .*:
      s/\([^)]\)//g;
      Which will strip off all braced strings, including the braces.
      --
      Alfie
      um, this regex doesn't work - I think you meant .* at end, but even then it won't work because it would only match the first set of braces.

      cLive ;-)

      Update: - ah yes, with a g. I also "saw" a $1 that wasn't there. Otherwise, why (remember) it?

Re: Re: Text elimination within a string
by Beatnik (Parson) on Apr 08, 2001 at 16:30 UTC
    Ofcourse you could consider the Death to Dot Star! node :|

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
      Except in this case, a greedy match is required.

      The second example is 'death to dot star' compliant, but is still making an assumption (that all text in braces to be removed is in upper case)

      Using:

      \([^)]*\)
      would only match first set of braces.

      So .* is appropriate here. honest :)

      cLive ;-)

      Update: Should also begin match with a ^. Hmmm, oops.