title: Editing string with analyze-string in XSLT
body: <p>I am using the following function in php to load an xml doc into an xslt document, output xml, and replace document.xml in the word docx:</p>
  
  <pre><code>$xmlDocument = new DOMDocument();
  $xmlDocument-&gt;load('xml/' . $xmlfile);
  
  $xsltDocument = new DOMDocument();
  $xsltDocument-&gt;load($xsltFile);
  
  $xsltProcessor = new XSLTProcessor();
  $xsltProcessor-&gt;importStylesheet($xsltDocument);
  </code></pre>
  
  <p>So I usually use this function in the XSLT file to pull an XML var: </p>
  
  <pre><code>&lt;xsl:value-of select="PORT_REQUEST/WICIS/REMARKS" /&gt;
  </code></pre>
  
  <p>However, because XML vars are loaded directly into the XSLT document, I cannot use my friendly PHP reg exp's, and I am struggling greatly trying to figure out how to make this work. I just need to pull the XML var (Telephone # in 1112223333 format) and put it in 111-222-3333 format.</p>
  
  <p>This is what i have:</p>
  
  <pre><code>            &lt;xsl:analyze-string select="PORT_REQUEST/NUMBER_PORTABILITY/ADMINISTRATIVE/ATN"
                  regex="(^.{3})|(.{4}$)|((?&lt;=(^.{3}))(.*?)(?=(.{4}$)))"&gt;
  
                    &lt;xsl:matching-substring&gt;
                    &lt;xsl:number value="regex-group(1)" format="001"/&gt;
                    &lt;xsl:number value="regex-group(2)" format="001"/&gt;
                    &lt;xsl:number value="regex-group(3)" format="0001"/&gt;
                    &lt;/xsl:matching-substring&gt;
                  &lt;/xsl:analyze-string&gt;
  </code></pre>
  
  <p>And it is not working, what I get instead of the re-formatted telephone number variable is an empty xml document, as whatever error I'm causing kills the entire thing.
  Help</p>