Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created February 18, 2017 07:36
Show Gist options
  • Select an option

  • Save Kcko/b74842d1941e1bfcbbb429502eaf26ed to your computer and use it in GitHub Desktop.

Select an option

Save Kcko/b74842d1941e1bfcbbb429502eaf26ed to your computer and use it in GitHub Desktop.
Filter do Latte
<?php
public static function predlozky($string) {
/*
$string = preg_replace('~ ([akosvzAKOSVZ]) ~', ' $1&nbsp;', $string);
$string = preg_replace('~^([AKOSVZ]) ~', ' $1&nbsp;', $string);
return $string;
*/
$string = preg_replace('~ ([akosvuzAKOSVZ]) ~', ' $1&nbsp;', $string);
$string = preg_replace('~^([AKOSVZ]) ~', ' $1&nbsp;', $string);
// predlozky, tituly, jednotky
for($i = 1; $i <= 3; $i++)
$string = preg_replace('~( |&nbsp;)(i|na|ve|pod|nad|od|do|před|ke|ku|ze|bez|ob|pro|při|po|skrz|za|Ing|MUDr|JUDr|Mgr|Bc|BcA|Ing. arch|MVDr|PhDr|RNDr|Pharmr|ThLic|ThDr|prof|doc|PaeDr|Dr|PhMr) ~', '$1$2&nbsp;', $string);
$string = preg_replace('~(Na|Ve|Pod|Nad|Od|Do|Před|Ke|Ku|Ze|Bez|Ob|Pro|Při|Po|Skrz|Za) ~', '$1&nbsp;', $string);
// en
for($i = 1; $i <= 3; $i++)
$string = preg_replace('~( |&nbsp;)(for|the|its|high-school|was|of|in|on|an|a|are|who|is|we|to|as|and|by|from|has|be|about|I) ~', '$1$2&nbsp;', $string);
$string = preg_replace('~(For|The|Its|High-school|Was|Of|In|On|An|Are|Who|Is|We|To|As|And|By|From|Has|Be|About|I) ~', '$1&nbsp;', $string);
// ru
$string = preg_replace('~( |&nbsp;)(в|с|и|из|на|со) ~i', '$1$2&nbsp;', $string);
// veliciny
$string = preg_replace('~([0-9]{1,}) (m{1,2}|cm|dm|ml|l|dcl|dl|g|kg|%|dkg|kg|s|A|K|cd|mol|rad|sr|Hz|N|Pa|J|W|C|V|F|Ω|S|Wb|T|H|lm|lx|Bq|Gy|Sv|kat)( |\.|\,|$)~', '$1&nbsp;$2$3', $string);
// procenta
//$string = preg_replace('~([0-9]{1,}) %~', "$1&nbsp;%", $string);
// kalendarni data
$string = preg_replace('~(\d{1,})\. (\d{1,})\. (\d{1,})~', "$1.&nbsp;$2.&nbsp;$3", $string);
//$string = preg_replace('^(([ ][a-zA-Z\&]{1,2})|([a-zA-Z0-9 ,\.\(][0-9]{1,5}))[ ]^','$1&nbsp;', $string);
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment