diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 16c1c9fe8..6335c7d94 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -156,6 +156,7 @@ import java.util.Set; import java.util.concurrent.CancellationException; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.UnsupportedAudioFileException; @@ -1170,14 +1171,24 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (replaceDialog.result) { final String txt = replaceDialog.searchField.getText(); if (!txt.isEmpty()) { - final String replacement = replaceDialog.replaceField.getText(); final SWF swf = getCurrentSwf(); new CancellableWorker() { @Override protected Void doInBackground() throws Exception { int findCount = 0; - Pattern pat = Pattern.compile(Pattern.quote(txt), replaceDialog.ignoreCaseCheckBox.isSelected() ? Pattern.CASE_INSENSITIVE : 0); + boolean ignoreCase = replaceDialog.ignoreCaseCheckBox.isSelected(); + boolean regexp = replaceDialog.regexpCheckBox.isSelected(); + String replacement = replaceDialog.replaceField.getText(); + if (!regexp) { + replacement = Matcher.quoteReplacement(replacement); + } + Pattern pat; + if (regexp) { + pat = Pattern.compile(txt, ignoreCase ? Pattern.CASE_INSENSITIVE : 0); + } else { + pat = Pattern.compile(Pattern.quote(txt), ignoreCase ? Pattern.CASE_INSENSITIVE : 0); + } List textTags = new ArrayList<>(); for (Tag tag : swf.tags) { if (tag instanceof TextTag) { diff --git a/src/com/jpexs/decompiler/flash/gui/SearchDialog.java b/src/com/jpexs/decompiler/flash/gui/SearchDialog.java index 9dd078b1d..d466741d0 100644 --- a/src/com/jpexs/decompiler/flash/gui/SearchDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/SearchDialog.java @@ -88,9 +88,8 @@ public class SearchDialog extends AppDialog implements ActionListener { JPanel checkPanel = new JPanel(new FlowLayout()); checkPanel.add(ignoreCaseCheckBox); - if (!replace) { - checkPanel.add(regexpCheckBox); - } else { + checkPanel.add(regexpCheckBox); + if (replace) { checkPanel.add(replaceInParametersCheckBox); }