This formula did the trick.
You are the best!
😊

El lunes, 24 de febrero de 2020, 12:08:24 (UTC-6), ThePorgie escribió:
>
> I would then include the line above so the string needs "Name"
> <key1><!\[CDATA\[NAME\]\]></key1>\n\s+<value><!\[CDATA\[(.+?)\]
>
> again with a \1 in the replace before hitting extract.
>
> Will that do what you need?
>
>
> On Monday, February 24, 2020 at 12:54:43 PM UTC-5, Miguel Perez wrote:
>>
>> Thank you, ThePorgie.
>>
>> Unfortunately it doesn't work for me.
>>
>> I should've said that there are many values using this syntax, like this:
>> <field>
>>     <key1><![CDATA[NAME]]></key1>
>>     <value><![CDATA[John Appleseed]]></value>
>> </field>
>> <field>
>>     <key2><![CDATA[Company]]></key2>
>>     <value><![CDATA[Google]]></value>
>> </field>
>>
>>
>> As you can see, there are two keys, but the very next line says *value* 
>> for both of them. That is my main concern.
>>
>> I want *value1* for each item on the list, but its defining *key* is in 
>> the line above with that CDATA formatting.
>>
>> Any ideas?
>>
>> El lunes, 24 de febrero de 2020, 11:01:22 (UTC-6), ThePorgie escribió:
>>>
>>> Put "\1" (no quotes) in the replace field and then Extract with
>>> <value><!\[CDATA\[(.+?)\]
>>>
>>> Will that work for ya?
>>>
>>>
>>>
>>> On Monday, February 24, 2020 at 11:44:36 AM UTC-5, Miguel Perez wrote:
>>>>
>>>> Hi,
>>>>
>>>> I'm fairly new to RegEx and I need your help.
>>>>
>>>> I process many XML files in my job. Most of them are formatted 
>>>> correctly, that is:
>>>> <key1>Value</key1>
>>>> <key2>Value</key2>
>>>>
>>>> For those I search for values using:
>>>>
>>>> <key1>.*?</key1>
>>>> And it works like a charm.
>>>>
>>>> But then I have this one source that formats its XML files with CDATA 
>>>> fields like this:
>>>> <field>
>>>>     <key><![CDATA[NAME]]></key>
>>>>     <value><![CDATA[John Appleseed]]></value>
>>>> </field>
>>>> In this example they are trying to say that the value *NAME* is *John 
>>>> Appleseed*. Rather than putting it as a key/value pair, they do that 
>>>> weird syntax.
>>>>
>>>> What GREP pattern can I use to extract all the names for this 
>>>> formatting?
>>>>
>>>> I am open to other solutions, like BASH scripts and Applescript. I'm 
>>>> desperate.
>>>>
>>>> Thank you for your help, friends.
>>>>
>>>> 🙂
>>>>
>>>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/b9ca09c3-6ffe-4402-8291-42f7e4d6d593%40googlegroups.com.

Reply via email to