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).