Reputation: 864
for example match any folder name except files that have dot(.) before extension
I try [^\.]
and .+[^\.].*
nothing work
Upvotes: 21
Views: 43969
Reputation: 225281
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.)
Upvotes: 39
Reputation: 109
Don't bother with regex for that, which is expensive. Here's a faster example (in php)
foreach($files as $file)
{
// ignore dot files
if( 0 === strpos($file,'.') ) continue;
...
}
Upvotes: 0