mardi 3 avril 2018

Regular expression to find/extract XPath within a string

Does anyone know, how tu build RELIABLE regular experesion to extract XPath from string? I have theese four examples:

1) not((xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:FormaSubjektu != "Společnost"))

2) not((/my:Fields/my:NZ-ObjednatelVSeznamuExistuje = string(false())))

3) not((../my:NZ-Subjekt-Title = "" and not(xdUtil:Match(string(../../my:NZ-Objednatel-Existuje/my:Objednatel), "\d+"))) or (../../my:NZ-ObjednatelVSeznamuExistuje = string(true()) and ../../my:NZ-Objednatel-Existuje/my:NZ-Subjekt-PridatNeboUpravitAdresu-Group/my:NZ-Subjekt-PridatNeboUpravitAdresu = string(false())) or (../../my:NZ-Objednatel-Existuje/my:NZ-Subjekt-PridatAdresu-Group/my:NZ-Subjekt-PridatAdresu = string(true())))

4) xdFormatting:formatString(xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:CenaJeNeprekrocitelnaPoznamka,"string","plainMultiline")

But there can be many more variations, for example without namespace prefixes... I have following pattern, but it doesn't work for fourth example:

(xdXDocument:get-DOM()/|../|\b()/)[a-zA-Z0-9u00a1-\uffff0-]+(/\S*)?|(dfs:[a-zA-Z0-9u00a1-\uffff0-]+/)[a-zA-Z0-9u00a1-\uffff0-]+(/\S*)?

Aucun commentaire:

Enregistrer un commentaire