9 lut 2014

Dodanie przed nazwą ulicy przedrostka ul.

Dodanie w bazie danych dodać przed nazwą ulicy przedrostek „ul.”

SELECT
    ulica,
    concat('ul. ', ulica)
FROM
    miasta_biura
WHERE
    ulica REGEXP '^ul.' <> 1
    AND ulica REGEXP '^Al.' <> 1UPDATE miasta_biura
SET
    ulica = concat('ul. ', ulica)
WHERE
    ulica REGEXP '^ul.' <> 1
    AND ulica REGEXP '^Al.' <> 1SELECT ulica
FROM
    miasta_biura
WHERE
    ulica REGEXP '^ul.[^ ]'

-- **********************

SELECT
    ulica,
    REPLACE(ulica, 'ul.', 'ul. ')
FROM
    miasta_biura
WHERE
    ulica REGEXP '^ul.[^ ]'
UPDATE
    miasta_biura
SET
    ulica = REPLACE(ulica, 'ul.', 'ul. ')
WHERE
    ulica REGEXP '^ul.[^ ]'

-- **********************

SELECT
    ulica,
    REPLACE(ulica, 'al.', 'Al.')
FROM
    miasta_biura
WHERE
    ulica REGEXP '^Al.'
UPDATE
    miasta_biura
SET
    ulica = REPLACE(ulica, 'al.', 'Al.')
WHERE
    ulica REGEXP '^Al.'
8 gru 2012

Wyrażenie reguralne wykorzystanie w funkcji replace

function open_popup(url, w, h, t, l) {
  let param = popup_param(w, h, t, l);
  let Win = window.open("",'popup_window',param);
  Win.focus();
  return Win;
};
  
function program_print() {
  let el = document.getElementById('program-list');
  if(el!=undefined) {
    let Win=open_popup();
    let html=el.innerHTML;
    html=html.replace('program_print','window.print','g');
    html=html.replace(/<input\b[^>]*?/ig, "");
    Win.document.write(html);
  }
};

Wyrażenie regularne wykorzystanie w funkcji replace. Kod html pobierany jest z doma strona i przekley do nowego okna.