3

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.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Alnedru
  • 2,573
  • 9
  • 50
  • 88
  • 1
    ID="[^"]+" should do it. Untested though, and don't remember the particulars with Notepad++'s regex flavor. – Corbin Mar 16 '12 at 08:01
  • Just a tip: before replacing anything you can use the Notepad++ "Mark" function to check if your replacing is correct – Gabber Mar 16 '12 at 08:24

2 Answers2

7

Try the following

ID="{[a-zA-Z0-9-]+}"
Bogdan Emil Mariesan
  • 5,529
  • 2
  • 33
  • 57
  • 1
    You could also be more specific, replacing the '+' with the exact count of characters: ID="{[a-zA-Z0-9-]{36}}" – Anthony K Sep 25 '12 at 02:06
1

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

Community
  • 1
  • 1
Gabber
  • 5,152
  • 6
  • 35
  • 49
  • @Benoit it seems that you didn't even read my whole answer, the problem was already pointed out before my first edit. Assuming the file is all like the example my answer works fine. Assuming the file has multiple guids in a single line, using np++ v 5.9, the edited answer works fine. – Gabber Mar 16 '12 at 13:33