From: Eyal Oren Date: 2005-10-19T20:16:58+09:00 Subject: Re: attaching code to run on regular expression match thanks. that might work, but the problem is I think in the unions of the regexps that I use, see example: because of the unions, I don't really want to decide after the match what to do with it, but rather state it in the constituent regexp's (e.g., I would like to say in the ImplicitWiki regexp what should happen if it is encountered) ExplicitWiki = /\[\[([^\]]+)\]\]/ # CamelCase followed by some non-word character, e.g. 'CamelCase.' ImplicitWiki = /([A-Z]+[a-z]+[A-Z]+\w*)\W/ # <...>, no space inside brackets Uri = /<([^<>]+)>/ # dc:title Prefix = /(\w*):(\w+)/ # "hello" Literal = /"([^"]*)"/ Wiki = Regexp.union ExplicitWiki, ImplicitWiki Pred = Regexp.union Wiki, Uri, Prefix Obj = Regexp.union Pred, Literal Annotation = /(#{Pred})\s*(#{Obj})\s*\./ Variable = /(\?\w+)/ UriPattern = Regexp.union Variable, Pred LiteralPattern = Regexp.union Variable, Obj Query = /\[\?\s+#{UriPattern}\s+#{UriPattern}\s+#{LiteralPattern}\]/