RE: back references in regexen

I agree this can be a handy feature, but I don't think we want to diverge
from the XML Schema regular expression syntax except for facilities that
require more than boolean matching. The other consideration is that we want
to stick to a core subset of features that are widely available in existing
regular expression libraries, to make life livable for implementors.

Michael Kay

> -----Original Message-----
> From: Tobias Reif [mailto:tobiasreif@pinkjuice.com] 
> Sent: 21 May 2003 14:51
> To: public-qt-comments@w3.org
> Subject: back references in regexen
> 
> 
> 
> about
> http://www.w3.org/TR/xmlschema-2/#regexs
> 
> Hi
> 
> It would be very handy to have a back reference mechanism in 
> the regexen 
> spec use by XSLT etc. Much more succinct code could be 
> written. (unless 
> I miss an existing feature)
> 
> Demo
> 
>   code = "foo = 'bar'"
>   # also works when " is used as attribute value delimiter
> 
>   code =~ /([^\s=]+)(\s*)(=)(\s*)(['"])([^\5]+)(\5)/
> 
>   (1..7).each do |i|
>     print i.to_s+': '
>     p eval('$'+i.to_s)
>   end
> 
> brings
> 
>   ruby backref.rb
>   1: "foo"
>   2: " "
>   3: "="
>   4: " "
>   5: "'"
>   6: "bar"
>   7: "'"
> 
> 
> A concrete Use Case
> 
> Marking up XML code listings.
> 
> XSLT: (slightly outdated) 
> http://www.pinkjuice.com/howto/vimxml/xslt/tinydbk2xhtml/marku
p_xml.xslt2
Sample output:
http://www.pinkjuice.com/howto/vimxml/intro.xml (at the bottom)

Tobi

-- 
http://www.pinkjuice.com/

Received on Wednesday, 21 May 2003 12:55:22 UTC