Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++ regular expression replacement

Hello i have here a big file and i need to replace some values so i have to use regular expression: can anyone help me and tell how to do that?

<FieldRef ID="{FE652450-8A96-416E-AAE4-F85BE196A249}" Name="CG"  DisplayName="CG"/>
  <FieldRef ID="{AAA6ABCD-CE07-4D0E-A689-773DD47F4D64}" Name="Statut"  DisplayName="Statut"/>
  <FieldRef ID="{F13A3B87-47DE-4DE2-B480-FE1126B0D5E2}" Name="ElementCMin"  DisplayName="Element C Min"/>

So in this lines i need to replace ID="{guid}" by empty string.

like image 290
Alnedru Avatar asked Sep 21 '26 12:09

Alnedru


2 Answers

Try the following

ID="{[a-zA-Z0-9-]+}"
like image 78
Bogdan Emil Mariesan Avatar answered Sep 24 '26 04:09

Bogdan Emil Mariesan


This regex should do

ID="\{.*\}"

Do a replace with empty following line and you are done. However, if you have more occurrences of something ending in }", notepad will do the wrong thing, applying the replace function on this line

text1 ID="{F13A3B87-47DE-4DE2-B480-FE1126B0D5E2}" 
text ID="{F13A3B87-47DE-4DE2-B480-FE1126B0D5E2}" text2

will remove everything except

text1 text2

however look at Notepad++ non-greedy regular expressions if you need to resolve this problem.

EDIT: If you have notepad++ version 5.9 or more the corret regex is

ID="\{.*?\}"

It stops at the first curly brace in the row

like image 20
Gabber Avatar answered Sep 24 '26 03:09

Gabber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!