Reputation: 167
I have results for FOOD, FOOD20 and FOOD 30
but have other results that come from FOOD
such as DOGFOOD, CATFOOD
using REGEX.
I am trying to place an EXACT filter by using:-
FOOD|FOOD20|FOOD30
to extract just these results instead of using REGEX. Unfortunately this is returning 0 results.
Is there another work around for this?
Upvotes: 1
Views: 1467
Reputation: 421
An exact filter is a literal string match, so you're explicitly looking for something matching all of "FOOD|FOOD20|FOOD30" exactly.
If you want to ensure that the value is exactly FOOD
, FOOD20
or FOOD30
, use REGEX matching, but precede each value with a caret (^
), which marks the beginning of the line, and follow each value with the dollar sign ($
), which marks the end of the line.
So, your REGEX expression would be:
^FOOD$|^FOOD20$|^FOOD30$
If your idea is to track anything that starts with "FOOD", followed by a number, and then ends, you can simplify your expression to the following:
^FOOD[0-9]*$
(The [0-9]* part means match the numbers 0 to 9 zero or more times, so it matches when there are no numbers after FOOD
, or when there are some.)
This will match FOOD
, FOOD20
, FOOD30
, FOOD99
and FOOD100
, but not CATFOOD
, DOGFOOD10
, etc.
Upvotes: 3