text parsing question
Jim Ault
JimAultWins at yahoo.com
Fri Jun 9 17:40:36 EDT 2006
One solution is below:
Assumption
you are referring to the first instances of 112 & 110 without checking for a
match to the image size attributes (they may not always be present)
Caution: your email version word wraps such that the string
"images/go.png" has a space and cr inserted. I am assuming this is not what
you meant since it would be a faulty src attribute.
One approach is to END UP with the following and convert cr to spaces:
468
443
112
110
images/go.png
------------stat code--------------------
put fld 1 into textBlock
--do this first in case the image name contains "px"
put offset("src=""e,textBlock) into srcPos
--assume possible malformed src string.. note spaces added
if srcPos = 0 then put offset("src =""e,textBlock) into srcPos
if srcPos = 0 then put offset("src = ""e,textBlock) into srcPos
if srcPos = 0 then put offset("src= ""e,textBlock) into srcPos
get char srcPos to -1 of textBlock
replace quote with cr in it
put line 2 of it into imgStr
--now get the numbers
-- since you cannot always control the format of an html page
replace cr with space in textBlock -- these would get in the way
replace "px" with cr in textBlock
filter textBlock without empty --just in case an empty line is created
replace ":" with space in textBlock
repeat for each line LNN in textBlock
put the last word of LNN & cr after thinTextBlock
end repeat
--add the imgStr
put imgStr into line -1 of thinTextBlock
put thinTextBlock into fld 2
end test
----------- end code --------------
Jim Ault
Las Vegas
On 6/9/06 1:51 PM, "Josh Mellicker" <josh at dvcreators.net> wrote:
> You have a series of lines, like this:
>
>
> <div id="go" style="position:absolute; left:468px; top:43px;width:
> 112px; height:110px;z-index:1; visibility:visible"><img src="images/
> go.png" width="112" height="110" border="0"></div>
>
>
> All you want out of this line is:
>
> 468 43 112 110 images/go.png
>
>
> What is the cool way to write a function to extract these strings?
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list