On 04 May 2007, at 09:46, Andrew Keller wrote:

> Can RB's XML parser parse this?  If not, then what can?
>
> {
>      jobSpecification = {
>          name = "progress demo 1";
>          taskSpecifications = {
>              0 = {arguments = ("agent app.pl", "-xgrid", 1, 10);
> command = "/usr/bin/perl"; };
>          };
>      };
> }

A bunch of regex's should do

I'm no regex expert so I'm sure someone else can do this better but  
something like

   dim s as string
   dim r as regex
   dim m as RegExMatch
   dim args as string
   dim command as string

   s = "{" + chr(13) + "jobSpecification = {" + chr(13) + "name =  
""progress demo 1"";" + chr(13) + "taskSpecifications = {" + chr(13) +_
   "0 = {arguments = (""agent app.pl"", ""-xgrid"", 1, 10);" + chr 
(13) + "command = ""/usr/bin/perl""; };" + chr(13) + "};" +_
   "1 = {arguments = (""agent app2.pl"", ""-xgrid"", 1, 10);" + chr 
(13) + "command = ""/usr/bin/perl""; };" + chr(13) + "};" +_
    chr(13) + "};" + chr(13) + "}"

   //A jobSpec is "{ jobSpecification (.*) } (greedy true)
   //The name is from the jobspec name = \".*";
   //The taskspec is from the jobspec taskSpecification = { .* };
   //Each step in the task is \n = {(arguments =(.*); command =  
"(.*)"; };

   // get the job
   r = new RegEx
   r.Options.DotMatchAll = true
   r.SearchPattern = "{.*jobSpecification.*=.*{.*name.*=.*\"".*\"";.* 
(taskSpecifications.*=.*{.*});.*};.*}"
   m = r.Search(s)

   s = m.SubExpressionString(1)

   // get the args and command ... seems like there
   r = new RegEx
   r.Options.DotMatchAll = true
   r.Options.Greedy = false
   r.SearchPattern = ".*\d.*=.*{arguments.*=.*\((.*)\);.*command.*=.* 
\""(.*)\"";.*};"

   m = r.Search(s)

   while m <> nil
     args = m.SubExpressionString(1)
     command = m.SubExpressionString(2)

     m = r.Search
   wend
  
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to