develooper Front page | perl.beginners | Postings from March 2002

RE: Regexp needed

Thread Previous
From:
Jason Larson
Date:
March 5, 2002 06:16
Subject:
RE: Regexp needed
Message ID:
9F560B2FB311D6119A7D00204840E2059F2102@swbtexch2.swbanktx.com
> -----Original Message-----
> From: Jorge Goncalvez [mailto:goncal11@col.bsf.alcatel.fr]
> Subject: re:Regexp needed
> 
> 
> hi, i have this:
> my ($Path) = $MountsPath =~ /(.+?)cygwin/;
> but I wanted to get rid of the "/".
> because $MountsPath could be c:/cygwin or c:/xyz/cygwin or 
> c:/xyz/zyx/cygwin and 
> i wanted $Path = c: or c:/xyz or c:/xyz/zyx .
> And now $Path= c:/ or c:/xyz or c:/xyz/zyx.
> How can I do ?
> thanks.

Just add the "/" to your match outside the grouping, like so:
  my ($Path) = $MountsPath =~ /(.+?)\/cygwin/;

Hope this helps...
Jason


CONFIDENTIALITY NOTICE:

************************************************************************

The information contained in this ELECTRONIC MAIL transmission
is confidential.  It may also be privileged work product or proprietary
information. This information is intended for the exclusive use of the
addressee(s).  If you are not the intended recipient, you are hereby
notified that any use, disclosure, dissemination, distribution [other
than to the addressee(s)], copying or taking of any action because
of this information is strictly prohibited.

************************************************************************

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About