I need to extract just the filename (no file extension) from the following path....
\\\\my-local-server\\path\\to\\this_file may_contain-any&character.pdf<
Try this:
[^\\]+(?=\.pdf$)
It matches everything except back-slash followed by .pdf
at the end of the string.
You can also (and maybe it's even better) take the part you want into the capturing group like that:
([^\\]+)\.pdf$
But how you refer to this group (the part in parenthesis) depends on the language or regexp flavor you're using. In most cases it'll be smth like $1
, or \1
, or the library will provide some method for getting capturing group by its number after regexp match.