Regex - Search for Name of Current File
-
I want to write a regular expression that matches the name of the file currently being searched.
The purpose is to find hyperlinks in an HTML file which point to the file itself, but without the # character in the href attribute. Such links are almost always a mistake, but apps which look for broken links don’t find it, because the link isn’t broken (it points to its own file!).
I Googled for this kind of regex, but the only hits returned were on how to extract file names from paths, which isn’t what I need.
Is it possible to match the name of the current file in a regular expression?
-
Sorry, the regex engine knows nothing about the “file metadata”, which includes its name.
However, if you use a scripting plugin like PythonScript, you can make a script that does know the file’s name, and has access to a regex engine so that it can search for the file’s name in the active file (or in any other file, for that matter).
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login