summaryrefslogtreecommitdiff
path: root/support/latexindent/LatexIndent/Replacement.pm
diff options
context:
space:
mode:
Diffstat (limited to 'support/latexindent/LatexIndent/Replacement.pm')
-rw-r--r--support/latexindent/LatexIndent/Replacement.pm18
1 files changed, 7 insertions, 11 deletions
diff --git a/support/latexindent/LatexIndent/Replacement.pm b/support/latexindent/LatexIndent/Replacement.pm
index e864a96895..c1df5db131 100644
--- a/support/latexindent/LatexIndent/Replacement.pm
+++ b/support/latexindent/LatexIndent/Replacement.pm
@@ -66,21 +66,17 @@ sub make_replacements {
if ( ${$_}{this} and ${$_}{substitution} );
if ( ${$_}{this} ) {
+ #
# *string* replacement
- # *string* replacement
- # *string* replacement
- my $this = qq{${$_}{this}};
- my $that = ( defined ${$_}{that} ) ? qq{${$_}{that}} : q();
- my $index_match = index( ${$self}{body}, $this );
- while ( $index_match != -1 ) {
- substr( ${$self}{body}, $index_match, length($this), $that );
- $index_match = index( ${$self}{body}, $this );
- }
+ #
+ my $this = quotemeta( ${$_}{this} );
+ my $that = ( defined ${$_}{that} ) ? qq{${$_}{that}} : q();
+ ${$self}{body} = join( $that, split( $this, ${$self}{body} ) );
}
else {
+ #
# *regex* replacement
- # *regex* replacement
- # *regex* replacement
+ #
# https://stackoverflow.com/questions/12423337/how-to-pass-a-replacing-regex-as-a-command-line-argument-to-a-perl-script
my $body = ${$self}{body};