Search code examples
regexnotepad

How to Use wildcard Regex Notepad++


Hello i am new in Regex of the Notepad++ Replace Option i have alot of files that start with

#include <right/someheader.h>

and i need to convert them to

#include "someheader.h"

without loosing the someheader.h i did try using this replace method:

#include <right/.*>  

but it wont get the value of someheader.h it would simply replace it like this:

#include ".*"

Is it possible to make it work using Regex ? in Notpad++ i have seen this: https://superuser.com/questions/637476/using-wildcard-search-replace-in-notepad But i dont understand how to apply to my needs could anyone help? thanks


Solution

  • Replace the matches found by the regex:

    <[^\/]*\/([^>]*)>
    

    with

    "$1"
    

    Click for Demo

    Explanation:

    • < - matches a <
    • [^\/]* - matches 0+ occurrences of any character except a /
    • \/ - matches a /
    • ([^>]*) - matches 0+ occurrences of any character except a > and stores it in Group 1
    • > - matches a >

    Before Replacement:

    enter image description here

    After Replacement:

    enter image description here