Replacer and regexes

10 views
Skip to first unread message

Eddy Vanlerberghe

unread,
Jan 7, 2026, 3:33:39 AM (3 days ago) Jan 7
to ZAP User Group
Hi,

Am I correct in assuming that the replacement texts in the replacer addon are static, so do not include any part of the matching text?

What I hope to achieve is to use a more dynamic replacement text. E.g. consider the following sed pattern:

cat bla.txt | sed 's/\(.*\)/line: \1/'

this will effectively put "line: " in front of every line in the input file.

Is something like this possible in replacer?

A quick look in zap-extensions/addOns/replacer/src/main/java/org/zaproxy/zap/extension/replacer/ExtensionReplacer.java shows a private static method with the name "replace(...)" but from what I can make of it, the replace ment text is fixed.

Regards,

Eddy.

thc202

unread,
Jan 7, 2026, 4:02:21 AM (3 days ago) Jan 7
to zaprox...@googlegroups.com
Hi,

It does allow to use the captured groups, e.g.:
line: $1

See the following for the supported syntax:
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html

and how the matcher and replaceAll works.

Best regards.

Eddy Vanlerberghe

unread,
Jan 7, 2026, 7:51:32 AM (3 days ago) Jan 7
to ZAP User Group
Thanks, that works indeed.
Reply all
Reply to author
Forward
0 new messages