Note that there are some explanatory texts on larger screens.

plurals
  1. PORegex + Php preg_replace
    text
    copied!<p>Following up from my last question @ <a href="https://stackoverflow.com/questions/7049245/regex-match-before-string-comes-up">stackoverflow.com/questions/7049245/</a></p> <p>I got a couple of answers with the perfect regex code i was looking for. But now i have a new problem, i cant seem to get any regex code with a php preg_replace working. I have been searching but no success.</p> <p>The current code i have is: </p> <pre><code>(PHP) $nclist = file_get_contents('**REMOVED LINK**'); $thenc = explode("\n",$nclist); foreach ($thenc as $row) { $nc .= $row."&lt;br&gt; "; } $search = array ('^(.*)(\((?:-?\d{1,4}\.\d{1}(?:, |\))){3} to \((?:-?\d{1,4}\.\d{1}(?:, |\))){3})(?= distance)(.*)$/ &amp;&amp; do { my ($pre, $no_numbers, $post) = ($1, $2, $3); $no_numbers =~ s/\d+\.\d+/#/g; print "$pre$no_numbers$post\n"; }'); $replace = array (''); $final = $nc; echo preg_replace($search, $replace, $final); print_r($cheat); </code></pre> <p>And it displays the output of $nc fine, but doesnt want to apply the regex against it. Any php help on how to get it working please? Thanks</p> <p>Also if you didnt see the last question i had, i needed all the parts that matched</p> <blockquote> <p>(-90.8, 64.0, 167.5) to (-90.7, 64.0, 167.3)</p> </blockquote> <p>removed, or at least censored into </p> <blockquote> <p>(#, #, #) to (#, #, #)</p> </blockquote> <p>Again, the regex answers from the last question worked perfectly, so i would like to use that. </p> <p>EDIT1: Ah, i remembered i had the print_r there to test something else, so i removed it, but now its just a blank page.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload