Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: how to parse only until the LAST ")" ?
Pages: [1] Print
Author Topic: how to parse only until the LAST ")" ?  (Read 204 times)
parser
Guest


Email
how to parse only until the LAST ")" ?
« on: October 11, 2005, 03:24:29 AM »

Suppose I have a sentence
blah blah (a + (b + c)) blah blah

I want to parse ONLY the first "(" and LAST ")" to get the expression "a + (b + c)" how to parse only until the last ")" (and not intermediate parenthesis ) ?
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
how to parse only until the LAST ")" ?
« Reply #1 on: October 11, 2005, 05:18:39 AM »

Code:
>> non-paren: complement charset "()"
== make bitset! #{
FFFFFFFFFFFCFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
}
>> balanced-parens: [#"(" any non-paren opt balanced-parens any non-paren #")"]
== [#"(" any non-paren opt balanced-parens any non-paren #")"]
>> parse "blah blah (a + (b + c)) blah blah" [to #"(" copy result balanced-parens to end]
== true
>> result
== "(a + (b + c))"
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: how to parse only until the LAST ")" ?
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 05, 2008, 11:40:20 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2233 Posts in 581 Topics by 1854 Members
Latest Member: Vqxykkpz

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc