I guess that this has had to be asked before, but cannot find anything about it. I also think that maybe the answer is just right there but I can't see it either.
So, if QRegularExpression::match() has not a match, how do I know the position of the character that made the validation fail?
I'm pretty sure that internally, there should be some variable storing the "current position" as the string is being evaluated.
Yes, maybe there is backtracking in that evaluation so if the exact failing char is hard to get, at least the last good one could be easier.
Any hints? Thank you.
Edit (2022-08-08):
I'm starting to feel like it's possible that no one asked this before, in fact, considering how people think I am asking something like "why my regex does not work". Not my case.
This is not about a particular regular expression. It's about Qt's class QRegularExpression.
I apologize if I've not been clear. I've tried to explain the best I could since the very beginning.
Anyway, let's say you have one string, to be evaluated against some (ANY) regex. No match is found. Then I want to know, if possible, the point where the evaluation failed.
This regex: "abc" This string: "abd", failing position: 2
This regex: "abc" This string: "acb", failing position: 1
This regex: "abc" This string: "xyz", failing position: 0
I feel very stupid asking this, mostly because I think it's a very basic question.
But it's not what you immediately think at first glance. I swear I searched for answers the most I could, but everything I got was about errors in the regexes themselves.