Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Splitting a complex string
#1
Hello,

I am having problems with the right code to split the following string:

18803bd54-63c1d-4d41f-aa2bf-be0d1aa9490c2d
#2
Code:
Copy      Help
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
,
A new blog on QM coding and automation.

The Macro Hook
#3
This won't work because the format of the string is
cef6-42d6-afb4-2b6bf488b291

I cannot figure this out.
#4
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.

Code:
Copy      Help
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]
#5
Sorry to bother you again. But i changed the output to:

c9fb7l13a-3020f-4d88a-ac2d5-3fe5b73019f05
#6
end 1 "error"

must be

end "error"

or

end "error" 1


Maybe easier to understand if all will be in separate lines.

Code:
Copy      Help
int i
i=findrx(s4 "<response alpha=''(.+?)'' beta=''(.+?)''" 0 0 b)
if(i<0)
,end "error"


Forum Jump:


Users browsing this thread: 1 Guest(s)