Regex To Match Everything Before The Last Dot

A regular expression to match everything until the last dot(.). Can be useful in extracting the filename without the file extension in a string.

/.*(?=\.)/g

Matches:

  • regexpattern.com
  • regexpattern.min.jpg
  • https://regexpattern.com/text.php

See Also: