I am not using a coding language. This has to be straight regex.
I need to add a variable length of whitespace between two strings. The string I am passing to the regex has the number of whitespaces in the string itself and will need to be replaced:
string1 *27* string2
so I need to insert 27 whitespaces into this string between string1 and string 2
\*(\d+)\*
This is my capture and it appear to be working, but I was trying to setup my replace with this:
\s{$1}
or this:
$&\s{$1}
So how would you do it? I am using expresso for my validation, but not all the regex patterns are supported by the text engine I am using.
This is not possible with straight regex. Regex would need some sort of parsing capabilities to use the captured variable and translate it into repeating spaces.
The way you want replace to work is not possible, also. As the replace portion of a regex is a straight text replace, and not another regex evaluator....it would be kind of cool to have some sort of recursive regex though :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With