Reputation: 550
I need a regex for the last word after the word typedef, except for the last character. I know that ([^typedef]*)$
would give me the last word after typedef, but that would include the last character.
For example if I had the line type long long integer;
, I want a regex that would give me integer
, not integer;
. If this helps, the last character will always be a semicolon.
Upvotes: 2
Views: 1297
Reputation: 784998
This is the regex that should work for you:
^typedef.*?\s(\w+)\s*;
Last word is available in matching group #1.
Upvotes: 3
Reputation: 1604
Add a period after your parenthesis to match 1 character but not capture it: ([^typedef]*).$
Upvotes: 0