Re: [F&O] regular expressions: non-capturing groups

[note this is not a response from a WG member]

In this case you don't need non capturing groups, you can just grab all
potential keywords (eg [a-z]+) in the analyze-string, then test to see
what you have before deciding whether to add the keyword markup, eg
changing your code to
<xsl:template match="programlisting[@role='pseudocode']/text()">
  <xsl:analyze-string select="."  regex="[a-z]+">
      <xsl:when test=". = ('while','true','if','else','end')">
      <span class="keyword">
        <xsl:copy-of select="."/>
        <xsl:copy-of select="."/>


bash-2.05b$ java -jar saxon8.jar in.dbx through.xslt 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns=""><head>
      <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8"/>
   <title>Some Code</title><link rel="stylesheet" href="style.css" type="text/css" /></head><body><div>
  <h1>Some Code</h1>
  <pre><code class="pseudocode">
  <span class="keyword">while</span>  <span class="keyword">true</span>  foo 
  <span class="keyword">while</span> <span class="keyword">true</span>  foo 


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

Received on Tuesday, 23 November 2004 11:03:10 UTC