We help IT Professionals succeed at work.

How to replace all the first set of forward slashes with four forward slashes in Perl?

Tolgar
Tolgar asked
on
Medium Priority
362 Views
Last Modified: 2012-08-15
How can I convert this:

//something/dir1/dir2/dir3/

Open in new window


or

///something/dir1/dir2/dir3/

Open in new window


or

////something/dir1/dir2/dir3/

Open in new window


or

////////////////////something/dir1/dir2/dir3/

Open in new window


TO

////something/dir1/dir2/dir3/

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Commented:
$str =~ s~^/+~////~;

Author

Commented:
Can I also write it like this?

$str =~ s{^/+}{////};
CERTIFIED EXPERT

Commented:
Yes

Explore More ContentExplore courses, solutions, and other research materials related to this topic.