Page 1 of 1
Why does matchChunk not see HTML tags?
Posted: Sun Dec 02, 2018 12:12 am
by kaveh1000
Consider the following code
Code: Select all
put "good morning" into fld 1
get matchChunk(fld 1, "(mor)", temp_start, temp_end)
put the htmlText of fld 1 into htmltemp
get matchChunk(htmltemp, "(mor)", temp_start, temp_end)
temp_start and temp_end are 6 and 8 as expected, in the first case. But in the second case I expect them to be 9 and 11, because htmltemp should be
Why is the <p> not taken into account?
Re: Why does matchChunk not see HTML tags?
Posted: Sun Dec 02, 2018 12:58 am
by bogs
put the htmlText of fld 1 into htmltemp
My guess would be because there is no <p> in
htmlTemp.
For instance, the top field in this picture gets the raw text in a url, then puts the 'htmlText' of that into field 2. When you do that, all tags are stripped I think...

- html and htmlText...
Re: Why does matchChunk not see HTML tags?
Posted: Sun Dec 02, 2018 1:05 am
by kaveh1000
But when I put
before the last line, I get
in the message box
Re: Why does matchChunk not see HTML tags?
Posted: Sun Dec 02, 2018 1:05 am
by dunbarx
Why the parentheses within the quoted literal?
get matchChunk(fld 1, "(mor)", temp_start, temp_end)
Didn't you mean:
Code: Select all
get matchChunk(fld 1, "mor", temp_start, temp_end)
Craig Newman
Re: Why does matchChunk not see HTML tags?
Posted: Sun Dec 02, 2018 1:11 am
by bogs
I could be wrong, its been known to happen

Re: Why does matchChunk not see HTML tags?
Posted: Sun Dec 02, 2018 1:58 am
by kaveh1000
No Craig. You need the brackets so matchChunk remembers what it found. Try each of these two lines in the Message box:
Code: Select all
get matchChunk("hello", "e", temp_start, temp_end); put temp_start
Code: Select all
get matchChunk("hello", "(e)", temp_start, temp_end); put temp_start
Only the second one gives you "2" correctly.

Re: Why does matchChunk not see HTML tags?
Posted: Sun Dec 02, 2018 6:50 pm
by dunbarx
Ah. I should read the dictionary more often.
But I do get both the "6,8" and "9,11" in your code snippet.
Craig
Re: Why does matchChunk not see HTML tags?
Posted: Sun Dec 02, 2018 8:13 pm
by kaveh1000
Now I am getting them too. Have no idea what I did wrong!!! Anyway looks like happy ending.
Re: Why does matchChunk not see HTML tags?
Posted: Sun Dec 02, 2018 8:40 pm
by dunbarx
I am positive, starting with Hyoercard in 1987, that here and there a code run will fail, and then, without changing a thing, work just fine.
This is due either to gremlins or to problems in my brain. I do not believe it can be due to both.
Craig