<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    That's not a digit; that's an ASCII 1.<br>
    For the digit "1", you'd need<br>
    4> re:replace("012345", "0(...)45", "x\\1\61").<br>
    which of course doesn't work either.<br>
    <br>
    "man pcresyntax" really does indicate that "\g{N}" would be the
    expected PCRE syntax for the job:<br>
    <blockquote>BACKREFERENCES<br>
               \n             reference by number (can be ambiguous)<br>
               \gn            reference by number<br>
               \g{n}          reference by number<br>
               \g{-n}         relative reference by number<br>
    </blockquote>
    but "\\g" does not appear to be supported in any form...<br>
    <br>
    And the workaround I can think of - using an empty quoted section as
    a separator - doesn't work either:<br>
    2> re:replace("012345", "0(...)45", "\\1\\Q\\E6789").<br>
    [[<<"123">>,<<"QE6789">>]]<br>
    <br>
    /Erik<br>
    <br>
    Den 08-03-2012 19:01, Gustav Simonsson skrev:
    <blockquote cite="mid:178afdee-be35-4afc-9b5e-db8a5a60639b@knuth"
      type="cite">
      <pre wrap="">
Is this what you want todo?

re:replace("012345", "0(...)45", "x\\1\1").  
[[<<"x">>,<<"123">>,<<1>>]]

Regards,
Gustav Simonsson

Sent from my PC

----- Original Message -----
</pre>
      <blockquote type="cite">
        <pre wrap="">From: "Vance Shipley" <a class="moz-txt-link-rfc2396E" href="mailto:vances@motivity.ca"><vances@motivity.ca></a>
To: <a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
Sent: Thursday, 8 March, 2012 4:58:19 PM
Subject: [erlang-questions] backquotes in re:replace/3

Is there a syntax supported which allows us to insert a back
reference in a replacement followed directly by digits?  I
haven't found one yet.

   Eshell V5.9  (abort with ^G)
   1> re:replace("012345", "0(...)45", "\\1bcde").
   [[<<"123">>,<<"bcde">>]]
   2> re:replace("012345", "0(...)45", "\\16789").
   [[<<>>]]
   3> re:replace("012345", "0(...)45", "\\g{1}6789").
   [<<"g{1}6789">>]


--
        -Vance
_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>

</pre>
      </blockquote>
      <pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>