Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
simple regex plz
sachin_sharma78
can anybody provide me with
my $outputName = "dir1\dir2\dir3" ; ##### it can be dir1\dir2\dir3\dir4 or dir1\dir2
my $filename = "filename.html" ;
# INSERT regex here
so that I will have
$output =
www.dir1.com\dir2\dir3\filename.html
; ##### likewise
www.dir1.com\dir2\dir3\dir4\filename.html
or
www.dir1.com\dir2\filename.html
thanx in advance
Find more posts tagged with
Comments
Phil
Try this
my $outputName = "dir1\\dir2\\dir3";
my $filename = "filename.html";
$outputName =~ m/^([^\\]*)\\(.*)/;
$output = "www.$1.com\\$2\\$filename";
Adam Stoller
Try this:
my $outputName = "dir1/dir2/dir3";
# note: the '\'s were changed to '/'s
my $filename = "filename.html";
(my $output = "$outputName/$filename") =~ s|^([^/]+)|www.$1.com|;
[untested, but I think it should do what you want]
URLs - which is what it appears you are trying to create - only use '/' - they do not accept '\'
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
sachin_sharma78
Thanks Fish and phil , it worked...