I'm writing a regex that I need to catch strings that are plurial starting with "get". For instance getContacts
and getBuildings
should match the regex. However there are times where the text may equal getDetails or get**Details
. I do not want the regex to include these.
I can come up with a regex that includes the matching group "Details", but I want to exclude that capture group, not include it.
[Gg]et?\w+([Dd]etail)s
I'm not very strong at regex but heres my understanding of what I wrote:
match "g" or "G" followed by "et" then optionally any word character, then the matching group, followed by "s".
How can I exclude results that have the word "details"?
getDetailsAndBars
match or not?getInfo
match? your original regex appears to exclude that case.[Gg]et?
? The?
just makes thet
optional. Was that your intention?