in reply to string matching
#!/usr/bin/perl use strict; use warnings; my $string = 'https://somewebsite.com/'; if ($string =~ /^https/) { print "https success\n"; } if ($string =~ /\/$/) { print "trailing slash success\n"; }
Note I have used an un-escaped carat as an anchor to require matches start at the beginning of the string - I assume this is where your confusion originated.
Depending on what you are trying to do, you may consider checking out some of the useful modules of CPAN, such as Regexp::Common::URI.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: string matching
by llancet (Friar) on Feb 26, 2010 at 02:59 UTC |