Community
    • Login

    Regex - Search for Name of Current File

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 306 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Sylvester BullittS
      Sylvester Bullitt
      last edited by

      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?

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Sylvester Bullitt
        last edited by

        @Sylvester-Bullitt ,

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

        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors