Eyal Oren schrieb:
> 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}\]/

OK, thanks for your example. I think the regexp engine of Ruby 1.9 
called Oniguruma supports something like named sub-expressions, which 
might be what you need.

Regards,
Pit