Page 1 of 1
Regex delimiter
Posted: Wed Aug 19, 2009 3:39 pm
by frodo baggins
hello everybody
this is my first experience with runrev and so far it has been kinda like a roller coaster ride, one moment i'm awestruck , the next moment i'm almost scratching my head uncontrollably.
anyway what is the regex delimiter?
i have this regex matchtext("<h1 ="(.*?)">" ,matchedtext) and i tried \ as the delimiter but i got an error
i'd appreciate help in this
pardon my grammar, i'm in a bit of a hurry.
Posted: Wed Aug 19, 2009 4:20 pm
by dablock
I know what you mean, Frodo. Many things are amazingly easy then something seemingly simply is confounding.
You're using the correct literal character, "\". This works for me.
Code: Select all
on mouseUp
put "<a href=" & quote & "http://forums.runrev.com" & quote & ">RunRev Forum</a>" into tUrl
get matchText ( tUrl, "<a href=\"(.*?)\">", tMatchedText)
put tMatchedText
end mouseUp
This displays
Posted: Thu Aug 20, 2009 3:27 am
by frodo baggins
dablock wrote:I know what you mean, Frodo. Many things are amazingly easy then something seemingly simply is confounding.
You're using the correct literal character, "". This works for me.
Code: Select all
on mouseUp
put "<a href=" & quote & "http://forums.runrev.com" & quote & ">RunRev Forum</a>" into tUrl
get matchText ( tUrl, "<a href="(.*?)">", tMatchedText)
put tMatchedText
end mouseUp
This displays
Thanks a lot dablock, your code worked.
i had not added the command 'Get' before matchtext and hence the error
just one last question,
is there a way to get all the matches of a pattern into an array or something and then iterate over the them and print it?
I tried doing so but the variable got only the first match!
Also, Is there some sort of foreign function interface to c/c++ or some other language in runrev? I'm thinking of creating a pcre compatible regex package with named captures and all that if there is an ffi interface. The present regex library falls short on many counts in my opinion.
Posted: Thu Aug 20, 2009 6:03 am
by mwieder
There *is* an externals api, but it's about to get a major revision, so you'd probably want to wait until after the conference to get started on this.