Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Reverse Parsing

 [1/4] from: greggirwin::starband::net at: 27-Sep-2001 13:46


Is there an easy, obvious, way that I can't see to parse backwards with alternation capabilities? For example, I want to find the last word typed, so I search backwards from the caret position looking for any [tab space return]. I can search backwards with find, but it doesn't allow alternation (does it?). I can parse forwards, ignoring all but the last item I find, but is that the best approach? Any suggestions? --Gregg

 [2/4] from: al:bri:xtra at: 28-Sep-2001 8:25


> Is there an easy, obvious, way that I can't see to parse backwards with
alternation capabilities? For example, I want to find the last word typed, so I search backwards from the caret position looking for any [tab space return]. I can search backwards with find, but it doesn't allow alternation (does it?). I can parse forwards, ignoring all but the last item I find, but is that the best approach? Would reverse-ing the string first, then parse-ing work for you?
>> s: "a word at last ^-"
== "a word at last ^-"
>> head reverse s
== "^- tsal ta drow a" Andrew Martin ICQ: 26227169 http://zen.scripterz.org

 [3/4] from: joel:neely:fedex at: 27-Sep-2001 15:52


Andrew beat me to it... Andrew Martin wrote:
> > Is there an easy, obvious, way that I can't see to parse > > backwards with alternation capabilities? For example, ...
<<quoted lines omitted: 3>>
> >> head reverse s > == "^- tsal ta drow a"
... but remember to reverse the parsed results afterwards! reverse string parse to extract item(s) of interest reverse extracted item(s) -jn- -- This sentence contradicts itself -- no actually it doesn't. -- Doug Hofstadter joel<dot>neely<at>fedex<dot>com

 [4/4] from: greggirwin:starband at: 27-Sep-2001 15:28


Thanks guys! I figured I could do that as a last resort (overhead and all that). It's an easy solution for now and if I ever use it on a really big file and it eats my machine, I'll worry about it then. :) --Gregg

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted