Quick Regex Perl not terminated
perl, regex
Solution
You have a regex substitution without a replacement string. It should look like
s/PATTERN/REPLACEMENT/
and you have only
s/PATTERN/
so Perl is telling you that the substitution isn't terminated.
This program uses your regex to do what you want
use strict;
use warnings;
for (<DATA>) {
s/\[\[Image:(\w+?\.png)\|{0,1}(.*?)\]\]/<img src="$1" alt="$2"\/>/g;
print;
}
__DATA__
[[Image:wiki.png]]
[[Image:wiki.png|Wikipedia, The Free Encyclopedia.]]
output
<img src="wiki.png" alt=""/>
<img src="wiki.png" alt="Wikipedia, The Free Encyclopedia."/>
Problem
I'm trying to convert Wiki markup to HTML markup, i.e. ``` [[Image:wiki.png]] [[Image:wiki.png|Wikipedia, The Free Encyclopedia.]] ``` to ``` <img src="wiki.png" alt=""/> <img src="wiki.png" alt="Wikipedia, The Free Encyclopedia."/> ``` using a line of Perl ``` s/\[\[Image:(\w+?\.png)\|{0,1}(.*?)\]\]/g; print; ``` But Perl keeps throwing the error Substitution replacement not terminated It works in this RegExr test and changing the delimiter has not fixed the issue. Any insight would be much appreciated.