Posts: 7
Threads: 3
Joined: Nov 2006
Hello,
I am having problems with the right code to split the following string:
18803bd54-63c1d-4d41f-aa2bf-be0d1aa9490c2d
Posts: 1,769
Threads: 410
Joined: Feb 2003
ClearOutput
str a="response alpha=''18803b54-6c1d-4d4f-aabf-be0da9490c2d'' beta=''9bd46a13-f717-4665-b0d9-699d42528191'' url=''GenShield.aspx?ShieldId=9bd46a13-f717-4665-b0d9-699d42528191'' "
str b
a.findreplace("ShieldId=" "ShieldId")
b.gett(a 1 "=''")
out b
b.gett(a 3 "=''")
out b
b.gett(a 5 "=''")
b.findreplace("ShieldId" "ShieldId=")
out b
,
Posts: 7
Threads: 3
Joined: Nov 2006
This won't work because the format of the string is
cef6-42d6-afb4-2b6bf488b291
I cannot figure this out.
Posts: 11,926
Threads: 138
Joined: Dec 2002
Learn regular expressions. It will save you lots of time, and not only while working with QM. In most programs where can be used regular expression (eg to find text), regular expression syntax is identical or similar to QM.
str s=
;<?xml version="1.0" encoding="iso-8859-1"?>
;<response alpha="18803b54-6c1d-4d4f-aabf-be0da9490c2d" beta="9bd46a13-f717-4665-b0d9-699d42528191" url="GenShield.aspx?ShieldId=9bd46a13-f717-4665-b0d9-699d42528191" />
ARRAY(str) a
if(findrx(s "<response alpha=''(.+?)'' beta=''(.+?)'' url=''(.+?)''" 0 0 a)<0) end "error"
out a[1]
out a[2]
out a[3]
Posts: 7
Threads: 3
Joined: Nov 2006
Sorry to bother you again. But i changed the output to:
c9fb7l13a-3020f-4d88a-ac2d5-3fe5b73019f05
Posts: 11,926
Threads: 138
Joined: Dec 2002
end 1 "error"
must be
end "error"
or
end "error" 1
Maybe easier to understand if all will be in separate lines.
int i
i=findrx(s4 "<response alpha=''(.+?)'' beta=''(.+?)''" 0 0 b)
if(i<0)
,end "error"