Is it possible to pass a variable into the quantity designation in regex, the curly brackets, such that the amount of back slashes it looks for depends on how far to move back in the field (in this case a file path).
Essentially it should look back X number of back slashes (in a filepath) depending on the amount to move back, field [MoveBack]. [MoveBack] is a number type (integer/byte).
REGEX_Replace([Field1],"(.*)(\\..*){[MoveBack]}", "$1") + "\" + [Index] +"_" +[Title]
I try to pass the variable through but it does not work for me. Any tips would be helpful.
Thanks!
Solved! Go to Solution.
REGEX_Replace([Field1],"(.*)(\\..*){" + [Moveback] + "}", "$1") + "\" + [Index] +"_" +[Title]
you have to offset your [Moveback] with +s to add it to the string of the regexp pattern
You could build the regex formula using a formula tool to create it as a string and then wrap the regex tool in a macro that takes the regex formula in as a control parameter.
Hey @gwiz,
This is definitely achievable in the formula tool:
Make sure all your datatypes are strings or just convert them with the toString function
that didn't seem to work :/ can you clarify?
sure. The regexp pattern is just a string like any other string. So you can build it out using string concatenation.
I think your MoveBack, you said, was byte/integer right? so to append that into the string, it needs to be a string. So
REGEX_Replace([Field1],"(.*)(\\..*){" + tostring([Moveback]) + "}", "$1") + "\" + [Index] +"_" +[Title]
-SHOULD- do it. thanks to IraWatt for pointing that out. I didn't think about it.
No worries @gwiz !