Jessica Paloma
Jessica Paloma

Reputation: 43

Perl error in search and replace windows

I am trying to remove tag head using regex of mutiples files recursive in windows 10 using perl

forfiles /s /m *.html /c "perl -pi -e s/<head(?:.|\n|\r)+?</head>//g @path"

but I get this message and I dont understand what I wrong

Illegal division by zero at -e line 1.

Upvotes: 0

Views: 160

Answers (1)

Nahuel Fouilleul
Nahuel Fouilleul

Reputation: 19305

/ in </head> must be escaped with \ because / is the substitute delimiter or another delimiter can be used. for example s,<head(?:.|\n|\r)+?</head>,,g.

also as regex seems to be multi line perl switch -0777 can be used to unset record separator and read the whole file, otherwise input is split bynewlines before applying regex.

Upvotes: 1

Related Questions