PCREexample

pcre example

Query

Perl compatible regular expression:

Subject string

Result

(let ((match ((pcre (data (form-field 'query (current-node)))) (data (form-field 'subject (current-node))))))) (if match (node-list (make element gi: 'p (literal "Match from " (caar match) " to " (cdar match))) (map (lambda (x) (literal " '" x "'")) (cdr match))))

Source code:

<xsl:stylesheet xmlns:dsssl="http://www.askemos.org/2000/NameSpaceDSSSL" xmlns:mind="http://www.askemos.org/2000/CoreAPI" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 <xsl:template match="*[@type=&quot;read&quot;]">
  <html>
   <body bgcolor="white">
    <h2>pcre example</h2>
    <h3>Query</h3>
    <dsssl:form action="&apos;()" method="GET">
     Perl compatible regular expression:
    <dsssl:input name="query" type="text" dsssl:value="(data (form-field &apos;query (current-node)))"></dsssl:input><br></br>
     Subject string <dsssl:input name="subject" type="text" dsssl:value="(data (form-field &apos;subject (current-node)))"></dsssl:input><input type="submit"></input></dsssl:form>
    <h3>Result</h3>
    <dsssl:copy-of select="#CONTENT">
(let ((match ((pcre (data (form-field 'query (current-node))))
              (data (form-field 'subject (current-node)))))))
  (if match
      (node-list
        (make element gi: 'p (literal "Match from " (caar match)
                                      " to " (cdar match)))
        (map (lambda (x) (literal " '" x "'")) (cdr match))))
    </dsssl:copy-of>
   </body>
  </html>
 </xsl:template>
</xsl:stylesheet>

Diese Seite findet man von: overview, .




Letzte Modifikation: Wed, 11 Jun 2003 16:29:39 +0200

Autor(en): jfw,

Dokument Nummer A67bb0753e1676f81983e0ecf3a15b391 geliefert an public um Sun, 07 Sep 2008 19:48:54 +0200