Escape character for filtering?

Walton Sumner wsumner at im.wustl.edu
Thu Apr 6 18:01:47 EDT 2006


Is there an escape character that works with Rev's filter command? I would
like to filter a list of XML paths, and want to match things like
"...\Child[6]\...". I hoped to filter with expressions something like
"Child\[6\]", but this does not work. The following code illustrates that
"/" works fine, but "\[" does not.

I know that I can work around and use filters by replacing the [ and ] in
tList, but this is going to run quite often, and I think performance will
suffer noticeably. I could also make a single pass through the lines of
tList and evaluate each line with a transcript statement or two, but it
should be best to use a single filter command that can recognize \[\d\].

The 2.7 manual description of the filter command links to the regular
expression syntax, which is not quite what I need, AFAICT.

Any suggestions?

Here's code for a button to try the alternatives.


<code type="xtalk">
<!-- for Marielle Lange: do you still want this markup? -->

on mouseup
  local tList,tFilter,tFound,tFilterList = "/,[,\[,\[\d\],/Child"
  local tSkipMatch = "["
  
  repeat for each item tFilter in tFilterList
    put XMLPathList() into tList
    if tFilter is not among the items of tSkipMatch then
      put matchtext(tlist,tFilter) into tFound
    else 
      put "Skip" into tFound
    end if
    filter tList with "*" & tFilter & "*"
    answer XMLPathList() & CR & "filter string:" & tFilter & CR &\
    "matchText: " & tFound & CR & "filter command: " & CR &  tlist
  end repeat
  
end mouseup

function XMLPathList
  --sample formatted after Ken Ray's STS XML paths
  return "3/Root/Child[1]/Grandchild[1]" & cr &
"3/Root/Child[1]/Grandchild[2]"
end XMLPathList

</code>


Thanks,

Walton Sumner





More information about the use-livecode mailing list