Answer by abalter for Regex for string not ending with given suffix
If you are using grep or sed the syntax will be a little different. Notice that the sequential [^a][^b] method does not work here: balter@spectre3:~$ printf 'jd8a\n8$fb\nq(c\n' jd8a 8$fb q(c...
View ArticleAnswer by MatthewRock for Regex for string not ending with given suffix
The accepted answer is fine if you can use lookarounds. However, there is also another approach to solve this problem. If we look at the widely proposed regex for this question: .*[^a]$ We will find...
View ArticleAnswer by tombert for Regex for string not ending with given suffix
The question is old but I could not find a better solution I post mine here. Find all USB drives but not listing the partitions, thus removing the "part[0-9]" from the results. I ended up doing two...
View ArticleAnswer by FiveO for Regex for string not ending with given suffix
To search for files not ending with ".tmp" we use the following regex: ^(?!.*[.]tmp$).*$ Tested with the Regex Tester gives following result:
View ArticleAnswer by stema for Regex for string not ending with given suffix
You don't give us the language, but if your regex flavour support look behind assertion, this is what you need: .*(?<!a)$ (?<!a) is a negated lookbehind assertion that ensures, that before the...
View ArticleAnswer by JesperE for Regex for string not ending with given suffix
Try this /.*[^a]$/ The [] denotes a character class, and the ^ inverts the character class to match everything but an a.
View ArticleAnswer by Bill for Regex for string not ending with given suffix
Anything that matches something ending with a --- .*a$ So when you match the regex, negate the condition or alternatively you can also do .*[^a]$ where [^a] means anything which is not a
View ArticleAnswer by Kent for Regex for string not ending with given suffix
.*[^a]$ the regex above will match strings which is not ending with a.
View ArticleAnswer by Doorknob for Regex for string not ending with given suffix
Use the not (^) symbol: .*[^a]$ If you put the ^ symbol at the beginning of brackets, it means "everything except the things in the brackets." $ is simply an anchor to the end. For multiple characters,...
View ArticleRegex for string not ending with given suffix
I have not been able to find a proper regex to match any string not ending with some condition. For example, I don't want to match anything ending with an a. This matches b ab 1 This doesn't match a...
View Article