I am us Qt. I have a text string that I specifically look for a function call xyz.set_name()
, I want to capture the last occurrence of this call but negate it if the line that contains it starts with a #
. So far I got the regex to match the function call but I don't know how to negate the #
matched lines and I don't know how to capture the last occurrence, don't know why all the matches are put into one capture group.
[().\w\d]+.set_name\(\)\s*
This is what I want it to do
abc.set_name() // match
# abc.set_name() // don't match
xyz.set_name() // match and capture this one
Update for more clarification:
My text read like this when printed out with qDebug
Hello\nx=y*2\nabc.set_name() \n#xyz.set_name()
It's is a long string with \n
being as newline.
Update: a longer test string for test. I have tried all the suggested regex on this but they didn't work. Don't know what is missing. https://regex101.com/r/vXpXIA/1
Update 2: Scratch my first update, the \n
is a qDebug()
thing, it doesn't need to be considered when using regex.