Stuck on Reg-Ex again

Ken Ray kray at sonsothunder.com
Thu May 30 12:43:02 EDT 2002


Troy,

You have to declare your returning values as "locals" before they can be
used. Here's my script that works:

on mouseUp
  local tResult
  put "<hello>This is stuff</hello>" into tItem
  get matchText(tItem,"<hello>(.*)</hello>",tResult)
  put tResult
end mouseUp

Notice I had to "local" tResult before it would come back properly,
otherwise you get nothing. Also, I've been using MC 2.4.2's Perl-Compatible
Regular Expressions (PCRE) engine, which is awesome and will be rolled into
the next rev of Rev, so you'll be able to do really neat things like
look-ahead assertions, etc.

If you have access to MC 2.4.2, you might want to get on my beta-testing
list for an XML parsing library that I've just released that uses PCRE. If
so, send me an email off list.

Thanks,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/

----- Original Message -----
From: "Troy Rollins" <troy at rpsystems.net>
To: <use-revolution at lists.runrev.com>
Sent: Thursday, May 30, 2002 11:45 AM
Subject: Stuck on Reg-Ex again


> In the past, I've gotten some good advise about using Reg-Ex in Rev from
> this list - here we go again...
>
> I am trying to use matchText and Reg-Ex to parse some XML contents. It
> is pretty basic stuff, and the same reg-ex syntax works in other capable
> programs - yet consistently throws a script error in Rev. Well, that's
> not completely true - on some script variations no error is thrown,
> though no result is obtained either.
>
> This is the basis for what we are trying -
>
>      matchText
> (openTextContents,"<selectionTag>(.*)</selectionTag>",contentResult)
>    put contentResult ## returns nothing
>
> I have read that people are using Rev for XML on this list, and perhaps
> we only need a jump start in syntax. In fact, unless I am mistaken, I
> seem to remember such comments as "why don't you just use Rev's native
> ability to parse the XML?" Yet, there are no commands or references in
> the dictionary related to XML parsing. Anyone have a quick start
> tutorial to working with XML (or Reg-Ex) in Rev? The documentation
> nicely simplifies Reg-Ex syntax - yet never goes far enough - like
> relating it to Rev commands in a useful way. Jeanne told me some time
> ago, that there would be a bunch on this topic in the upcoming 1.1
> "Cookbook"... I guess that would now be the 1.1.1 cookbook? The 1.2
> cookbook? The 2.0 cookbook?
>
> Frustrated with simple parsing. Thanks in advance.
> --
> Troy
> RPSystems
> www.rpsystems.net
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list