Reputation: 3
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
Upvotes: 0
Views: 4023
Reputation: 2877
The regex to find what you're looking for would be this:
#include <right\/(.*)>
And you would want to replace it with:
#include "\1"
Anything inside brackets get stored in variables, which can be referenced with \1
, \2
, and so on. So this grabs anything after "right/", and stores it in the variable \1
.
Upvotes: 0
Reputation: 10360
Replace the matches found by the regex:
<[^\/]*\/([^>]*)>
with
"$1"
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:
After Replacement:
Upvotes: 1