in reply to Detecting whether forward slash is present in string
That aside, I would think of just concatenate the string, and turn double (or triple) slashes into single ones. The only problem with that approach is that the double slash at the start, right after the colon, should stay. so a plain
will not do.tr[/][]s
This will work:
After that, the resulting string will be in $url. It will not be the return value of the entire expression, don't make the mastake of returning it directly in a function.(my $url = "$string1/$string2") =~ s((://)|//+){ $1 || "/" }ge;
n.b. I'm inserting a slash myself, in case neither of the two strings contained a slash at their appropriate end.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Detecting whether forward slash is present in string
by davido (Cardinal) on Sep 14, 2004 at 08:24 UTC |