tags:

views:

42

answers:

2

I have an xml file with a list of items:

<Items
  ID="1B884B58-0C47-451B-956E-44866A7F3F91"
  Name="Home"
  TemplateID="BD5B78E1-107E-4572-90DD-3F11F8A7534E"
  MasterID="00000000-0000-0000-0000-000000000000"
  ParentID="70A77564-8D3F-459E-850F-FFC79CC97B38"
  Created="2009-07-17T12:18:57.247"
  Updated="2009-08-14T14:08:38.970"
/>

I need to run a regex that essentially looks at every GUID, and adds curly braces {} around the guid, e.g.

{B884B58-0C47-451B-956E-44866A7F3F91}
A: 

Replace [0-9A-F]{8}-(?:[0-9A-F]{4}-){3}[0-9A-F]{12} with {$0}

OR

Replace ([0-9A-F]{8}-(?:[0-9A-F]{4}-){3}[0-9A-F]{12}) with {$1}

Amarghosh
+1  A: 

There are multiple acceptable formats for GUIDs, but sticking only with the one you have specified:

 /([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})/{$1}/g
richardtallent