Hi,
I am trying to match substrings and if they match extract the complete string encapsulated by either actual quotes (") or encoded ". At runtime i generate the regex with the list of substring that need to match. In the example below, the regex generated looks for substrings - templates1 and templates2 enclosed by " or " Note that the given substring will be encapsulated by " only or " only but not combination of them.
Regex pattern - (?<replacestrings>"(.*templates1.*)"|"(.*templates1.*)"|"(.*templates2.*)"|"(.*templates2.*"))
Sample Source - <document documentid=\"100\" documentname=\"Office\" xmlns=\"\"><fields><fieldset id=\"field1\" label=\"office\"><field id=\"1\" value=\"<test office:folder="menu"office:filepath="top"office:template="office/templates1/folders/files/container" office:type="group" office:officefolder="office/templates2/test/folders/file"><field id=\"metatadata\" value=\"\" type=\"text\" label=\"metatadata\" property=\"\" /></fieldset></fields><devices /></edit>
Matches
1. office/templates1/folders/files/container
2. office/templates2/test/folders/file
Any clues to correct regex?
Thanks,
Extract values between "" or " for specif
Moderator: General Moderators
Replace " with "
If I were First I replaced " s with " and continue parsing replaced string;
first
$str = str_replace('"','"',$str);
and then preg_match;
so on...
first
$str = str_replace('"','"',$str);
and then preg_match;
so on...