kyriakos876 wrote:I understood everything (or at least I think I did) except for one thing. In the Substitute="(?U).*(\d+)$":"\1" what does the "\1" stand for? I mean in the previous example it stands for the number I want to match, but in this example we use (\d+) which means one or more numbers, so why do we need the "\1" if it matches all the numbers anyway ? I check the links your provided yet I didn't get that part.
You have what \1 means completely wrong...
A Substitute consists of the following components:
Substitute="text to search for":"replacement text"
In the case of a regular expression Substitute, where you have
RegExpSubstitute=1 on the measure, you are generally going to be using that to (capture) some part of the string. The tokens \1 \2 \3... etc. are used in the right hand side, the "replacement text" to indicate that you want to use the value from one or more of the (captures) that are on the left hand side.
String=OneTwoThreeFour
RegExpSubstitute=1
Substitute="One(.*)Three(.*)":"\1 comes between One and Three, which is before \2"
Produces "Two comes between One and Three, which is before Four"
So those numbered tokens are just a reference to the captures. They are almost identical to "StringIndex" on a WebParser measure.
So in our example above:
String=MyNumberIs12
Substitute="(?U).*(\d+)$":"\1"
You are (capturing) one or more numeric digits on the left hand side with
(\d+). Then you are replacing the entire string with the value of the first
\1 capture from the left hand side, or in this case the value "12".