How do you define/explain this Perl regex:
$para =~ s!//!/!g;
I know the s means search, and g means global (search), but not sure how the exclamation marks ! and extra slashes / fit in (as I thought the pattern would look more like s/abc/def/g).
Perl’s regex operators
s,mandtr( thought it’s not really a regex operator ) allow you to use any symbol as your delimiter.What this means is that you don’t have to use
/you could use, like in your question!means search and replace all instances of
'//'with'/'you could write the same thing as
or
or
if you really wanted but as you can see the first one, with all the backslashes, is very hard to understand and much more cumbersome.
More information can be found in the perldoc’s perlre