0

I'm trying to replace the list guid in this string from:

<Field Type=\"Lookup\" DisplayName=\"Human Resources Document Category\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" List=\"{28365191-64ab-4b28-9ebe-427d66ed4e3a}\" WebId=\"a033826b-2bc7-4f95-8054-2fd4423c53d0\" ShowField=\"Title\" Mult=\"FALSE\" UnlimitedLengthInDocumentLibrary=\"FALSE\" Group=\"Custom Columns\" ID=\"{b87d7bc5-43da-490d-8303-ecbb0702bcd3}\" SourceID=\"{a033826b-2bc7-4f95-8054-2fd4423c53d0}\" StaticName=\"Human_x0020_Resources_x0020_Document_x0020_Category\" Name=\"Human_x0020_Resources_x0020_Document_x0020_Category\" Version=\"1\" />

So I want to change List="{guid}" to "{b87d7bc5-43da-490d-8303-ecbb0702bcd3}"

Can't seem to find the regex for doing this. Trying a String.Replace but can't seem to do it.

Thanks

user3519261
  • 79
  • 1
  • 14

1 Answers1

0

Please try:

var input1 = "<Field Type=\"Lookup\" DisplayName=\"Human Resources Document Category\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" List=\"{28365191-64ab-4b28-9ebe-427d66ed4e3a}\" WebId=\"a033826b-2bc7-4f95-8054-2fd4423c53d0\" ShowField=\"Title\" Mult=\"FALSE\" UnlimitedLengthInDocumentLibrary=\"FALSE\" Group=\"Custom Columns\" ID=\"{b87d7bc5-43da-490d-8303-ecbb0702bcd3}\" SourceID=\"{a033826b-2bc7-4f95-8054-2fd4423c53d0}\" StaticName=\"Human_x0020_Resources_x0020_Document_x0020_Category\" Name=\"Human_x0020_Resources_x0020_Document_x0020_Category\" Version=\"1\" />";
var pattern1 = "(?<=List=\\\").*?(?=\\\")";
var replace = "{b87d7bc5-43da-490d-8303-ecbb0702bcd3}";
var res = Regex.Replace(input1, pattern1, replace);
Quinn
  • 4,394
  • 2
  • 21
  • 19