Added searchAndReplace functionality
This commit is contained in:
parent
07aa610a8f
commit
12a35c8db6
4 changed files with 52 additions and 2 deletions
|
|
@ -32,6 +32,7 @@ A package for manipulating and massaging HTML.
|
|||
use WebGUI::HTML;
|
||||
$html = WebGUI::HTML::cleanSegment($html);
|
||||
$html = WebGUI::HTML::filter($html);
|
||||
$html = WebGUI::HTML::searchAndReplace($html);
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
|
|
@ -127,6 +128,31 @@ sub filter {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 searchAndReplace ( html )
|
||||
|
||||
Replaces all occurrences of strings specified in the config file.
|
||||
|
||||
=over
|
||||
|
||||
=item html
|
||||
|
||||
The HTML segment you want to have search and replaced.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub searchAndReplace {
|
||||
my $content = shift;
|
||||
foreach my $search (keys %{$session{config}{searchAndReplace}}) {
|
||||
my $replace = $session{config}{searchAndReplace}{$search};
|
||||
$content =~ s/\Q$search/$replace/g;
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue