4 sty 2013

Zamiana przecinka na spacje przy użyciu regexp_replace

select
  a_title,
  regexp_replace(a_title, ' +', ' ', 'g')
from articles
where
  a_status = 't'
  and a_title ~ ' '
update articles
set
  a_title = regexp_replace(a_title, ',', ' ')
where
  a_status = 't'
  and a_title ~ ','
update articles
set
  a_title = regexp_replace(a_title, ' +', ' ', 'g')
where
  a_status = 't'
  and a_title ~ ' '
4 sty 2013

Wyrażenie regularne i preg_match

$test='http://kody.wig.pl/strony-stare-2006_11-all.html';
$test='http://kody.wig.pl/strony-nowe-2012_11-1233.html';
echo $test;
preg_match("/(-(?P([0-9]+|all)))?\.html$/", $test, $back);
print_r($back);
8 gru 2012

Tworzenie wyrażenia dla RegExp z wykorzystaniem złączenia stringów

var name_srch_comma = name_srch.replace(RegExp(", *","g"), '|');
//name_srch_comma = name_srch_comma.replace(',',', ');
var re=new RegExp("("+name_srch+")","gi");
var re_c=new RegExp("("+name_srch_comma+")","gi");
var tmp_data=data.split("");
console.log("("+name_srch_comma+")"); // (Warszawa|Polna)
desc=tmp_item[0]+', '+tmp_item[3];
desc=desc.replace(re_c,"<strong>$1</strong>");

Tworzenie ze złączenia stringów wyrażenia dla RegExp