Can a regex return a match that's not a part of the original string?

Posted by Vishnu on Stack Overflow See other posts from Stack Overflow or by Vishnu
Published on 2011-02-24T07:20:43Z Indexed on 2011/02/24 7:25 UTC
Read the original article Hit count: 201

Filed under:

I'm using an application that requires me to provide a regex for various files. It uses the matches from the regex to uniquely identify each file and then use a data store to retrieve metadata about these files.

there is however a problem with the application, so it assumes that the data which is used to identify each file is only numeric data. Hence, it stores the results of matches in integers.

I control the data store but not the names of the files. Since the application has a bug in it, I was hoping that I could use an encoding scheme to convert the non-numeric data to an integer. But for that I'd require the regex to return something that's not part of the original string as a match. Is this possible?

© Stack Overflow or respective owner

Related posts about regex