Another one regex question. How do I create a regular expression that will capture a part of the text and match that part in some other place?
For example suppose I have an expression "(ab[cd]) bbb (ab[cd])" It will match the following strings:
"abc bbb abc"
"abc bbb abd"
"abd bbb abc"
etc.
What I want to do is to take the first captured part of the text ‘abc’ and check that it also repeated at the end of the text, so those strings will produce such results:
"abc bbb abc - Success"
"abc bbb abd - Error"
"abd bbb abc - Error"
"abd bbb abd - Success"
Of course that example is simple and its possible to check that without using regular expressions, but the real example I have is more complicated and I want to stick with regex here.
Have a look at backreferences.