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

RE: Regexp needed

Thread Previous
Jason Larson
March 5, 2002 06:16
RE: Regexp needed
Message ID:
> -----Original Message-----
> From: Jorge Goncalvez []
> 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...



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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About