Find all occurences of substr which is in double quotes

General
Highlighted
Enthusiast

Find all occurences of substr which is in double quotes

I have a requirement to pick data in double quotes from the below format.

 

<ACCOUNTS><ACCOUNT ACCOUNTID="12345" ACCOUNTNAME="abc.com"/><ACCOUNT ACCOUNTID="78910" ACCOUNTNAME="xyz.COM"/></ACCOUNTS>

 

From the above, I need to pick values 12345, abc.com & 78910,xyz.com. When i try regular expression, its not getting all the values from the above data.

Could you please help.

2 REPLIES 2
Teradata Employee

Re: Find all occurences of substr which is in double quotes

Hi.

 

One quick-and-dirty solution to start with:

 

BTEQ -- Enter your SQL request or BTEQ command:
SELECT t.*
FROM TABLE (strtok_split_to_table(1,
'<ACCOUNTS><ACCOUNT ACCOUNTID="12345" ACCOUNTNAME="abc.com"/><ACCOUNT ACCOUNTID="78910" ACCOUNTNAME="xyz.COM"/></ACCOUNTS>',
'"')
RETURNS (outkey INTEGER, tokennum INTEGER, token VARCHAR(25) CHARACTER SET UNICODE) ) t
WHERE t.tokennum MOD 2 = 0
ORDER BY 1,2;


*** Query completed. 4 rows found. 3 columns returned.
*** Total elapsed time was 1 second.

outkey      tokennum    token
----------- ----------- -------------------------
          1           2 12345
          1           4 abc.com
          1           6 78910
          1           8 xyz.COM

 

It's returning the values as a reultset. 

 

HTH.

 

Cheers.

 

Carlos.

Enthusiast

Re: Find all occurences of substr which is in double quotes

Thank you, Carlos