this post was submitted on 12 Nov 2023
2 points (100.0% liked)
Emacs
7 readers
1 users here now
A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!
Get Emacs
Rules
- Posts should be emacs related
- Be kind please
- Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.
Emacs Resources
Emacs Tutorials
- Beginner’s Guide to Emacs
- Absolute Beginner's Guide to Emacs
- How to Learn Emacs: A Hand-drawn One-pager for Beginners
Useful Emacs configuration files and distributions
Quick pain-saver tip
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
On a POSIX filesystem (MacOS, Linux, BSD, etc.), any character except '/' can be part of a filename. So why are you limiting yourself to a couple of punctuation characters? The best regex to match filenames is: "[^/]+"
If you're using Windows, it gets a bit trickier, but for reading the filesystem, "[^/\\\\]+" seems like it should be adequate. If you want to make sure you can create a filename on Windows, you'd have to exclude a few more characters. Nevertheless, excluding invalid characters still seems like a better approach than trying to include all the valid ones.