Plugin: Regex Replace
This plugin is used for replacing strings in source and translation using regular expressions. Multiple Regex plugins can be used in a single Pipeline.
Class: LTGear.Flowme.Plugin.Regex.Replace
Pipeline Format: XLIFF (MT)
Parameters
RegexExpression: The regular expression pattern to match. (Required)
Replacement: The replacement string. (Required)
ApplyToSource: Apply Regex to source? (Default: No)
ApplyToTarget: Apply Regex to target? (Default: Yes)
Default Regex Options
The pattern is interpreted as a canonical .NET regular expression.
Matching is left-to-right and case-sensitive.
^
and$
match the beginning and end of the input string..
matches any character except\n
.Whitespace is treated as a literal space.
Culture-invariant matching is used.
Capturing groups can be implicit or explicit.
Auto-Incrementing Counter Support
The Regex plugin supports automatic counters in replacement strings, allowing you to insert incrementing numbers dynamically during replacements.
How It Works
Use
_COUNTER_
to insert a number that increases with each match.You can specify a starting number:
_COUNTER50_
,_COUNTER0_
, etc.The counter increases by 1 per match.
Invalid formats (e.g.,
_COUNTER-5_
) are ignored.
Examples
Input:
Start [item] and [item]
Replacement:
Product _COUNTER_
Result:
Start Product 1 and Product 2
Input:
[item] [item]
Replacement:
Item _COUNTER100_
Result:
Item 100 Item 101
Named and Numbered Group Support
You can reference captured groups in your replacement string:
Named groups: Use
${name}
to insert the value of a named group.Numbered groups: Use
$1
,$2
, etc., to insert the value of numbered groups.
Important: Use Braces to Avoid Ambiguity
When combining group references with _COUNTER_
, always wrap group numbers in braces to avoid misinterpretation:
Correct:
${1}_COUNTER10_${2}
Incorrect:
$1_COUNTER10_$2 # This may be interpreted as $110
Example
Input:
MANA and ANASta and HANA
Pattern:
(A)(N)A
Replacement:
${1}_COUNTER10_${2} _COUNTER20_
Result:
MA_COUNTER10_N _COUNTER20_ and A_COUNTER11_N _COUNTER21_Sta and HA_COUNTER12_N _COUNTER22_