some text
some text
some text
<1NLI>some text1NLI>
<1NLI>some text1NLI>
<2NLI>some text2NLI>
<2NLI>some text2NLI>
some text
some text
some text
some text
<1NLI>some text1NLI>
<1NLI>some text1NLI>
<2NLI>some text2NLI>
<2NLI>some text2NLI>
some text
some text
some text
some text
<1NLI>some text1NLI>
<1NLI>some text1NLI>
<2NLI>some text2NLI>
<2NLI>some text2NLI>
some text
####
some text
- some text
- some text
- some text
- some text
- some text
- some text
- some text
some text
- some text
- some text
- some text
- some text
- some text
- some text
- some text
some text
- some text
- some text
- some text
- some text
- some text
- some text
- some text
####
undef $/;
%oli = ("NLI" => "OL TYPE\"1\"", "ALI" => "OL TYPE\"A\"", "aLI" => "OL TYPE\"a\"", "RLI" => "OL TYPE\"I\"", "rLI" => "OL TYPE\"i\"");
open (FIN, "< C:\in.txt") || die "can't open";
$content = ;
$content =~s /(.*?\n)(?!<(?:[0-9]?NLI|[0-9](?:B|A|a|R|r)LI)>)/\n$1<\/OL>\n/gs;
$content =~s /(.*?\n)(?!<(?:[0-9]?BLI|[0-9](?:N|A|a|R|r)LI)>)/\n$1<\/UL>\n/gs;
$content =~s /(.*?\n)(?!<(?:[0-9]?ALI|[0-9](?:B|N|a|R|r)LI)>)/\n$1<\/OL>\n/gs;
$content =~s /(.*?\n)(?!<(?:[0-9]?aLI|[0-9](?:B|N|A|R|r)LI)>)/\n$1<\/OL>\n/gs;
$content =~s /(.*?\n)(?!<(?:[0-9]?RLI|[0-9](?:B|N|A|a|r)LI)>)/\n$1<\/OL>\n/gs;
$content =~s /(.*?\n)(?!<(?:[0-9]?rLI|[0-9](?:B|N|A|a|R)LI)>)/\n$1<\/OL>\n/gs;
$content =~s /(<(OL|UL)[^>]*>)((?:(?!<\/\2>)|.)*?)(<\/\2>)/$1.&rep($3.$4)/gse;
sub rep{
my ($line) = @_;
$line =~s /<(\/?)(?:N|B|A|a|R|r)LI>(?!\n<[0-9])/<$1LI>/gs;
$line =~s /<\/((?:N|A|a|R|r)LI)>(.*?\n)(?=(?:- |<\/OL>))/\n<$oli{$1}>$2<\/OL><\/LI>\n/gs;
$line =~s /<\/BLI>(.*?\n)(?=(?:
- |<\/OL>))/\n
$1<\/OL><\/LI>\n/gs;
$line =~s /(<(OL|UL)[^>]*>)((?:(?!<\/\2>)|.)*?)(<\/\2>)/$1.&rep1($3.$4)/gse;
return "$line";
}
sub rep1{
my ($line) = @_;
$line =~s /<(\/?)1(?:N|B|A|a|R|r)LI>(?!\n<2)/<$1LI>/gs;
$line =~s /<\/1((?:N|A|a|R|r)LI)>(.*?\n)(?=(?:- |<\/OL>))/\n<$oli{$1}>$2<\/OL><\/LI>\n/gs;
$line =~s /<\/1BLI>(.*?\n)(?=(?:
- |<\/OL>))/\n
$1<\/OL><\/LI>\n/gs;
$line =~s /<(\/?)2(?:N|B|A|a|R|r)LI>/<$1LI>/gs;
return "$line";
}
open (FOUT, "> C:\out.txt") || die "can't open";
print FOUT $content;