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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -