Nowadays, lots of web pages are created by applications. Some of them do not format the html well and one line could be extremely long with the same or similar pattern(s). In order to break them down, a substitute command in perl would help dramatically.
For example: Setting both $1 and $b to the following string:
Code: Select all
$a = $b = "a b c d a b c d a b c d a b";
Code: Select all
$a =~ s/(.*) b c (.*)/\1\2/g;
$b =~ s/(.*?) b c (.*?)/\1\2/g;
Code: Select all
$a = a b c d a b c d ad a b
$b = ad ad ad a b
The second regular expression (.*?) replaces each pattern (removes all " b c " from the string).
/g means global to replace all occurrences of the pattern.