Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

REGEX and padding

vishwakar
8 - Asteroid

Hi

 

i Need to extract the below information from this tag

 

<zone h='50000' id='8' name='Sheet 2' show-title='true' w='84000' x='0' y='50000' />

 

I have tried the below regex expression

 

^[ ]*<zone h='(.*?)' id='(.*?)' name='(.*?)' show-title='(.*?)' w='(.*?)' x='(.*?)' y='(.*?)' />$

 

Whats wrong with the above regex expression, It returns null.

 

 

Expecting it to return vaues

returnvalues.PNG

 

Thanks

Karthik

 

Uploaded the sample workflow.

17 REPLIES 17
JohnJPS
15 - Aurora

Hi Karthik,

Not sure I understand, but in the XML Parse example, it extracts the value of zone (which in your example is in fact NULL, as it's an empty tag with only attributes).  Assuming you have some XML elements that do contain a zone, that value would show up there.  It would then be easy to apply a filter where zone == name.  (But I'm guessing you mean something more involved than that; if so could you expound?)

vishwakar
8 - Asteroid

@johnJps

 

Yes there are many values with Zone but , I have an filter to get the zones only with names and I have updated the workflow. Let me know if I was not clear in explaining it.

 

Thanks

Karthik

jdunkerley79
ACE Emeritus
ACE Emeritus

Hi Karthik,

 

THe sample you sent the screenshot shows the standard xml " not the single quotes. So the Regex needs to be:

<zone\s*h="([^"]*)"\s*id="([^"]*)"\s*name="([^"]*)"\s*show-title="([^"]*)"\s*w="([^"]*)"\s*x="([^"]*)"\s*y="([^"]*)"\s*/>

See if that works for you.

 

James

vishwakar
8 - Asteroid

Hi Pulsar

 

Thanks for pointing that out, It worked for the above one. However I brought in a different file and the again the out put shows null. I guess the Regex needs to be dynamic in nature to handle them

 

I have used the below Regex which you have given

 

<zone\s*h="([^"]*)"\s*id="([^"]*)"\s*name="([^"]*)"\s*show-title="([^"]*)"\s*w="([^"]*)"\s*x="([^"]*)"\s*y="([^"]*)"\s*/>

 

Zone.PNG

 

Thanks for your time and helping me out 

 

Thanks

Karthik

jdunkerley79
ACE Emeritus
ACE Emeritus

This goes back to needing flexibility in the matching withing the regex.

 

 Try the attached

GarthM
Alteryx Alumni (Retired)

i know i'm late to the party and that there's already an accepted solution, but the attached may offer a bit more flexibility in the event you want to reuse elsewhere and/or need slightly more flexibility.

vishwakar
8 - Asteroid

Hi GarthM

 

I checked your soulton , It works perfectly for a single row input, However for multiple rows it concantes in to comma separated and just shows in one row. Can we show it in multiple rows, that would be great.

 

Thanks

Karthik

GarthM
Alteryx Alumni (Retired)

sure thing. here ya go!

Labels