for example match any folder name except files that have dot(.) before extension
I try [^\.]
and .+[^\.].*
nothing work
Yes, the dot regex matches whitespace characters when using Python's re module.
(dot) metacharacter, and can match any single character (letter, digit, whitespace, everything). You may notice that this actually overrides the matching of the period character, so in order to specifically match a period, you need to escape the dot by using a slash \.
in regex is a metacharacter, it is used to match any character. To match a literal dot in a raw Python string ( r"" or r'' ), you need to escape it, so r"\." Unless the regular expression is stored inside a regular python string, in which case you need to use a double \ ( \\ ) instead.
$ means "Match the end of the string" (the position after the last character in the string).
You need to anchor it:
^[^.]+$
That will match a string composed of any characters except for dots. Is that what you mean by "before extension"? If you mean "at the beginning", then ^[^.]
will do the trick.
But if this isn't, say, grep or something, and you have an actual programming language, this might be better accomplished there. (And even with grep it’s better to write just grep -v '^\.'
, for example.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With