andrisp Posted March 21, 2006 Report Share Posted March 21, 2006 str_replace('..','.0.','1...1'); preg_replace('/\.\./','.0.','1...1'); Neviens no šiem neatgriež 1.0.0.1, kā biju iecerējis, bet gan 1.0..1 Saprotu, ka tas notiek laikam tāpēc, ka notiek pirmā atrastā paterna pārklāšanās ar potenciālo otro atrasto paternu. Risinājums ? Nu - lai atgrieztos 1.0.0.1. Link to comment Share on other sites More sharing options...
Delfins Posted March 21, 2006 Report Share Posted March 21, 2006 return '1.0.0.1'; Jeb es kaut ko nesapratu? Link to comment Share on other sites More sharing options...
Stopp Posted March 21, 2006 Report Share Posted March 21, 2006 izlaid divreiz cauri tam str_replace Link to comment Share on other sites More sharing options...
Delfins Posted March 21, 2006 Report Share Posted March 21, 2006 $sp = '/\.\./'; $rp = '.0.'; $s = '1...1'; $tmps2 = $s; do { $tmps1 = $tmps2; $tmps2 = preg_replace($sp,$rp,$tmps1); } while ($tmps1 != $tmps2); Link to comment Share on other sites More sharing options...
andrisp Posted March 21, 2006 Author Report Share Posted March 21, 2006 (edited) Delfins: nē, tu laikam nesaprati. Man vajag lai es varētu padot arī piemēram 12..0.1. UPD: Ā pasteidzies gan :) Stopp: nu to protams es iedomājos, bet nepatīk tā. Edited March 21, 2006 by andrisp Link to comment Share on other sites More sharing options...
andrisp Posted March 21, 2006 Author Report Share Posted March 21, 2006 es pārveidoju šitā: while (strpos($str, '..') !== false) { $str = str_replace('..','.0.',$str); } Link to comment Share on other sites More sharing options...
Recommended Posts