H
Hal Vaughan
I know there's a way to do this, and I know it involves special uses of a
regex, but I can't remember the terms that apply, so I'm having trouble
searching for it. I want to take a line in a malformed HTML page like:
<OPTION Value = '1' >Book_Title_1
<OPTION Value = '2' >Book_Title_2
so it'll look like:
<OPTION Value = '1' >Book_Title_1</OPTION>
<OPTION Value = '2' >Book_Title_2</OPTION>
I know I can find the pattern by looking for something like:
$htmlpage =~ /<OPTION.*?>.*?$/
I THINK I remember that I can capture the wildcard part of the regex like:
$htmlpage =~ /<OPTION(.*?)>(.*?)$/
But when I try a substitution:
$htmlpage =~ s/<OPTION(.*?)>(.*?)$/<OPTION.*?>.*?</OPTION>$/g;
how do I get the selected sections from the search part to be included in
the replace part?
Thanks for any help on this. I'm not even sure what the name is for the
type of search/replace I'm trying to do is!
Hal
regex, but I can't remember the terms that apply, so I'm having trouble
searching for it. I want to take a line in a malformed HTML page like:
<OPTION Value = '1' >Book_Title_1
<OPTION Value = '2' >Book_Title_2
so it'll look like:
<OPTION Value = '1' >Book_Title_1</OPTION>
<OPTION Value = '2' >Book_Title_2</OPTION>
I know I can find the pattern by looking for something like:
$htmlpage =~ /<OPTION.*?>.*?$/
I THINK I remember that I can capture the wildcard part of the regex like:
$htmlpage =~ /<OPTION(.*?)>(.*?)$/
But when I try a substitution:
$htmlpage =~ s/<OPTION(.*?)>(.*?)$/<OPTION.*?>.*?</OPTION>$/g;
how do I get the selected sections from the search part to be included in
the replace part?
Thanks for any help on this. I'm not even sure what the name is for the
type of search/replace I'm trying to do is!
Hal