A great way to do this is to use negative lookahead:
^(?!.*bar).*$
The negative lookahead construct is the pair of parentheses, with the opening parenthesis followed by a question mark and an exclamation point. Inside the lookahead [is any regex pattern].
More Related Contents:
- Phone number regular expressions exact format
- Greedy vs. Reluctant vs. Possessive Qualifiers
- RegEx: Grabbing values between quotation marks
- Validating email addresses using jQuery and regex
- Searching for UUIDs in text with regex
- What regular expression will match valid international phone numbers?
- Extract a regular expression match
- Regular Expression to match only alphabetic characters
- Regular expression that doesn’t contain certain string [duplicate]
- Returning a regex match in VBA (excel)
- Regex to match month name followed by year
- Regex for alphanumeric, but at least one letter
- regex to match word boundary beginning with special characters
- Does the ‘o’ modifier for Perl regular expressions still provide any benefit?
- Microsoft office Access `LIKE` VS `RegEx`
- regular expression to match everything until the last occurrence of /
- What regular expression can never match?
- Regular Expression Validation For Indian Phone Number and Mobile number
- How do I perform a Perl substitution on a string while keeping the original?
- replace a unknown string between two known strings with sed
- How can I parse quoted CSV in Perl with a regex?
- htaccess force https and redirect www to non-www, but no other subdomains
- How to escape dollar sign ($) in a string using perl regex
- Checking for diacritics with a regular expression
- Filtering a diff with a regular expression
- Regular Expression usage with ls
- Match parenthesised block using regular expressions in vim
- RegEx for allowing alphanumeric at the starting and hyphen thereafter
- Difference between regex quantifiers plus and star
- Finding and removing Non-ASCII characters from an Oracle Varchar2