Regex match any string not containing dot character
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.)
Try ^[^.]+$
. BTW, you don't need to escape dot inside [].