<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I seem to be having some issues with the re: module any time a back reference is introduced.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">(yes, I ideally wouldn't use a regex, I have one place I really need to)</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Referencing the module manual here:</p>
<p style="margin-top:0;margin-bottom:0"><a href="http://erlang.org/doc/man/re.html" class="OWAAutoLink" id="LPlnk416354" previewremoved="true">http://erlang.org/doc/man/re.html</a></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">A specific example is given:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div><i>Consider, for example:</i><br>
<i>(.*)abc\1<br>
If the subject is "xyz123abc123", the match point is the fourth character. </i></div>
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0">However, I've simplified my code down to that exact example and I can't make it match:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>46> {ok, MP} = re:compile("(.*)abc\1").</div>
<div>{ok,{re_pattern,1,0,0,</div>
<div>                <<69,82,67,80,89,0,0,0,0,0,0,0,65,1,0,0,255,255,255,255,</div>
<div>                  255,255,...>>}}</div>
<div>47> re:run("xyz123abc123", MP, [{capture,all_names,binary}]).</div>
<div>nomatch</div>
<div><br>
</div>
I have written all manner of patterns without a back reference that return a match fine:
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>48> {ok, MP2} = re:compile("(.*)abc123").</div>
<div>{ok,{re_pattern,1,0,0,</div>
<div>                <<69,82,67,80,93,0,0,0,0,0,0,0,65,1,0,0,255,255,255,255,</div>
<div>                  255,255,...>>}}</div>
<div><span style="font-size: 12pt;">50> re:run("xyz123abc123", MP2, [{capture,all,binary}]).</span><br>
</div>
<div>{match,[<<"xyz123abc123">>,<<"xyz123">>]}</div>
<div><br>
</div>
<div>My platform:</div>
<div><br>
</div>
<div>
<div>Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:10] [hipe] [kernel-poll:false]</div>
<div><br>
</div>
<div>Eshell V9.3  (abort with ^G)</div>
<div><br>
</div>
<div>The presented syntax works perfectly fine in Ruby, further suggesting the regex is correct:</div>
<div><br>
</div>
<div>
<div>irb(main):001:0> /(.*)abc\1/.match("xyz123abc123")</div>
<div>=> #<MatchData "123abc123" 1:"123"></div>
<div><br>
</div>
<br>
</div>
Any assistance on this is appreciated.</div>
<br>
<p></p>
<br>
</div>
</body>
</html>