path - Regex check if a file has any extension -


i looking regex test if file has extension. define as: file has extension if there no slashes present after last ".". slashes backslashes.

i started regex

.*\..*[^\\] 

which translates to

.*          char, number of repetitions  \.          literal . .*          char, number of repetitions  [^\\]       char not in class of [single slash] 

this test data (excluding ##, comments)

\path\foo.txt            ## want capture line \pa.th\foo               ## regex captures line <-- problem here \path\foo                ## line correctly filtered out 

what regex this?

your solution correct. use this:

^.*\.[^\\]+$ 

sample @ rubular.


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -