Hi
Sorry for double posting, but another question. I've been using "%1_%2_%3_%4_%5" in match and replace in reg (1) to move words around. I find it really flexible and ituitive. But lets say i have a bunch of files and each file has different amount of words. I would I go about moving the last word of each file to in between words 3 and 4 for example? would I still be using "%1_%2_%3_%4_%5" somehow?
It gets a little more complicated... you will need to use
RegEx (1) without "
Simple" enabled and with
v2 flag active.
You have a name such as: 1_2_3_4_5_6
You want to move the last word 6 after 3.
Use
Match: (.*?_3_)(.*?)_([^_]+)$
Replace: \1\3_\2
Explanation:
Pattern: Use a capturing group to identify the parts of the string:
(.*?_3_)(.*?)_([^_]+)$
Breakdown:
.*?_3_ matches everything up to _3_ (lazy match to ensure _3_ is included).
(.*?) matches everything between _3_ and the last underscore (non-greedy).
([^_]+)$ captures the last part of the string after the final underscore.
Substitution:
Replace with \1\3_\2, which reorders the groups:
\1 is the part before _3_.
\3 is the last word.
\2 is the part that was originally after _3_.
Another question, how would i use "%1_%2_%3_%4_%5" on files with more than 10 words? using "%10" does not seem to work if i wanted to move the 10th word around. thanks.
Only 9 groups are supported with "Simple" RegEx in BRU.