Is it possible to match a certain pattern but return a different, arbitrary string (that is not necessarily embodied in the test string)? I want the regex to return the arbitrary string.
Embedded Perl code would do, or just handle the returning part with the surrounding programming language. But I am curious to know if it is possible to do just with a regex. Let me formulate it as a (wrong) if-statement pattern.
(?(?=test)"true"|"false")
I have no specific regex dialect in mind, but it would be great to be able to do this in a general-purpose language like C#, PHP, Perl, JavaScript or Python. So, please no dedicated software.
My understanding of regex tells me that you cannot return something which is not there (as revived by Jan), and strictly, a regex pattern returns only a true/false result saying whether it matched (as pointed out by Borodin). But still.