我试图将此字符串中的列表guid替换为:
<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\" />
所以我想改变List =&#34; {guid}&#34;到"{b87d7bc5-43da-490d-8303-ecbb0702bcd3}"
似乎无法找到执行此操作的正则表达式。尝试String.Replace
但似乎无法做到。
由于
答案 0 :(得分:0)
请尝试:
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);