Skip to content

MATCH_REPLACE

Cregrant edited this page Jun 11, 2023 · 3 revisions

[MATCH_REPLACE]

Allows you to edit text files in your project, such as .smali and .xml.

  • NAME: the name of the rule (optional)
  • TARGET: the path to the text file you want to change. Supports Variables, Glob pattern and Static replacements
  • MATCH: the text to be searched in the file
  • REGEX: true if the text in the MATCH field is a regular expression, false otherwise
  • REPLACE: the result found in the file will be replaced by this text. If empty, the found result will be deleted. Supports Variables. Supports expressions like ${GROUP0}, ${GROUP1} etc

Examples

Remove debugging information from all .smali files:

[MATCH_REPLACE]
TARGET:
smali*/*.smali
MATCH:
\.source .+|    \.line \d+|        \.local .+|    nop|    \.prologue|    \.end local .+|    \.restart local .+
REGEX:
true
REPLACE:
[/MATCH_REPLACE]

Replace every 2 empty lines with one in the file abc.smali, whose path is not exactly known:

[MATCH_REPLACE]
TARGET:
smali*/abc.smali
MATCH:
\R\R
REGEX:
true
REPLACE:

[/MATCH_REPLACE]

Replace all the letters f with j inside the res/layout/ folder:

[MATCH_REPLACE]
TARGET:
res/layout/*
MATCH:
f
REGEX:
false
REPLACE:
j
[/MATCH_REPLACE]

Remove all spaces inside all application activities:

[MATCH_REPLACE]
TARGET:
[ACTIVITIES]
MATCH:
 
REGEX:
false
REPLACE:
[/MATCH_REPLACE]

Clone this wiki locally