简体   繁体   中英

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.

请尝试以下方法

ID="{[a-zA-Z0-9-]+}"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM