mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 02:00:58 +00:00
regex replace
This commit is contained in:
@@ -156,6 +156,7 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.sound.sampled.LineUnavailableException;
|
import javax.sound.sampled.LineUnavailableException;
|
||||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||||
@@ -1170,14 +1171,24 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
|||||||
if (replaceDialog.result) {
|
if (replaceDialog.result) {
|
||||||
final String txt = replaceDialog.searchField.getText();
|
final String txt = replaceDialog.searchField.getText();
|
||||||
if (!txt.isEmpty()) {
|
if (!txt.isEmpty()) {
|
||||||
final String replacement = replaceDialog.replaceField.getText();
|
|
||||||
final SWF swf = getCurrentSwf();
|
final SWF swf = getCurrentSwf();
|
||||||
|
|
||||||
new CancellableWorker() {
|
new CancellableWorker() {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
int findCount = 0;
|
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<TextTag> textTags = new ArrayList<>();
|
List<TextTag> textTags = new ArrayList<>();
|
||||||
for (Tag tag : swf.tags) {
|
for (Tag tag : swf.tags) {
|
||||||
if (tag instanceof TextTag) {
|
if (tag instanceof TextTag) {
|
||||||
|
|||||||
@@ -88,9 +88,8 @@ public class SearchDialog extends AppDialog implements ActionListener {
|
|||||||
|
|
||||||
JPanel checkPanel = new JPanel(new FlowLayout());
|
JPanel checkPanel = new JPanel(new FlowLayout());
|
||||||
checkPanel.add(ignoreCaseCheckBox);
|
checkPanel.add(ignoreCaseCheckBox);
|
||||||
if (!replace) {
|
checkPanel.add(regexpCheckBox);
|
||||||
checkPanel.add(regexpCheckBox);
|
if (replace) {
|
||||||
} else {
|
|
||||||
checkPanel.add(replaceInParametersCheckBox);
|
checkPanel.add(replaceInParametersCheckBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user