If the entire string is inventory/getData
or inventory/get
then this will work as a positive match for inventory/get
but not inventory/getData
^inventory/get$
^
matches the start of the string and $
matches the end
This pattern asserts that the string ends with get, if it ends with getData it will not match
To examine the more complex case of matching a negation, here are some example strings to be matched
- 1) inventory/get
- 2) inventory/getData
- 3) inventory/snorkle
- 4) inventory/getReal
inventory/[^g][^e][^t][^D][^a][^t][^a]
matches 3 only. This is because the [^g][^e][^t]
section is a non match for the other examples
inventory/(?:[^g][^e][^t][^D][^a][^t][^a]|get.*)
matches all except for 2 -- not sure but perhaps this is what you are asking for? As you can see the negation is tailored to the test data