本文整理汇总了PHP中mb_ereg_replace函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_ereg_replace函数的具体用法?PHP mb_ereg_replace怎么用?PHP mb_ereg_replace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_ereg_replace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: csv_item_edit
function csv_item_edit($str) {
$str = mb_ereg_replace('"','""', $str);
//★★★★★★★★★★★★★★★★
return "\"".$str."\"";
//★★★★★★★★★★★★★★★★
$pos = strpos($str, ",");
if ($pos !== false) {
return "\"".$str."\"";
}
$pos = strpos($str, "\r");
if ($pos !== false) {
return "\"".$str."\"";
}
$pos = strpos($str, "\n");
if ($pos !== false) {
return "\"".$str."\"";
}
$pos = strpos($str, "\"");
if ($pos !== false) {
return "\"".$str."\"";
}
return $str;
}
示例2: fgetcsvWrapper
function fgetcsvWrapper($fp)
{
global $gzipEnabled;
if ($gzipEnabled) {
// FIXME エスケープが必要なデータが来ると壊れるよーー
$r = gzgets($fp, 4000);
// $r = "";
// $r = "";
// do {
// $r .= gzgets($fp, 4000);
// } while(mb_substr_count($r,'"') % 2 == 1);
if ($r !== FALSE) {
// 行末の\r\nは消してから分割
$r = mb_ereg_replace("\r?\n\$", "", $r);
return explode("\t", $r);
} else {
return FALSE;
}
} else {
// return fgetcsv($fp, 4000, "\t", '"');
$r = fgets($fp, 4000);
if ($r !== FALSE) {
// 行末の\r\nは消してから分割
$r = mb_ereg_replace("\r?\n\$", "", $r);
return explode("\t", $r);
} else {
return FALSE;
}
}
}
示例3: makefuzzyexplist
/**
* あいまい検索用正規表現の集合体を取得する。
*
* @param string もとになるキーワード
* @return array(string) あいまい検索用正規表現を集めた配列
*/
static function makefuzzyexplist($key)
{
//仮名は全角カタカナに、英数字・空白文字は半角に、 濁点付きの文字を一文字に、記号は全角に。
$_key = mb_strtolower(mb_convert_kana($key, 'KVCas'));
foreach (self::$han2zen_mark_table as $han => $zen) {
$_key = mb_ereg_replace(mb_ereg_quote($han), $zen, $_key);
}
//2文字以上での表現を1文字にする
foreach (self::$two2one as $from => $to) {
$_key = mb_ereg_replace($from, $to, $_key);
}
//文字により削除(表記ゆれまたはごみ)
$_key = mb_ereg_replace('[ッー・゛゜、。]', '', $_key);
//異体文字に対応する。
$char = array();
$len = mb_strlen($_key);
for ($i = 0; $i < $len; $i++) {
$c = mb_substr($_key, $i, 1);
$char[] = isset($GLOBALS['itaimojitable'][$c]) ? $GLOBALS['itaimojitable'][$c] : mb_ereg_quote($c);
}
//ちょっと違う単語を許すようにする
$list = self::makeagrepexplist($char);
//表記ゆれになる文字を挟み込む
$ret = array();
foreach ($list as $a) {
$ret[] = join('[・ーー]?', $a);
}
return $ret;
}
示例4: stremail
/**
* Formats a string to be used as an email (specifically strips whitespace
* from the beginning/end of the Email, as well as immediately before/after
* the @ in the Email).
* @deprecated StringFunctions class
*/
public function stremail($email)
{
$newemail = mb_ereg_replace("^[ \t]+|[ \t]+\$", "", $email);
$newemail = mb_ereg_replace("[ \t]+@", "@", $newemail);
$newemail = mb_ereg_replace("@[ \t]+", "@", $newemail);
return $newemail;
}
示例5: GetSpellSuggestions
public static function GetSpellSuggestions($strText)
{
$strCleanText = mb_ereg_replace('[…\\n\\.,:;\\\\!\\?0-9]+', ' ', $strText);
$strCleanText = str_replace(array('\\n', '\\r'), array(' ', ' '), $strText);
$strCleanText = mb_ereg_replace('http://[a-z\\-A-Z\\.]+', ' ', $strCleanText);
$strCleanText = strip_tags($strCleanText);
/**
* mozilla entitites: &xxx;
*/
$strCleanText = mb_ereg_replace('&[\\.\\-a-zA-Z\\-0-9]+\\;', ' ', $strCleanText);
/**
* keyboard shortcuts
*/
$strCleanText = mb_ereg_replace('[~&]', '', $strCleanText);
/**
* openoffice entities: %xxx %%xxx %%%xxx #xxx and so on
*/
$strCleanText = mb_ereg_replace('[\\$\\[\\#\\%]{1,3}[a-zA-Z\\_\\-0-9]+[\\$\\]\\#\\%]{0,3}', ' ', $strCleanText);
/**
* some characters that mess with the spellchecking
*/
$strCleanText = mb_ereg_replace('[\\(\\)]+', ' ', $strCleanText);
$strCleanText = mb_ereg_replace('[„”]', ' ', $strCleanText);
$strCleanText = mb_ereg_replace('[…\\n\\.,:;\\\\!\\?0-9]+', ' ', $strCleanText);
return self::GetSpellSuggestionsWithPspell($strCleanText, QApplication::$TargetLanguage->LanguageCode);
}
示例6: viewqueries
function viewqueries()
{
global $tplname, $usr;
global $viewquery_line, $noqueries, $bgcolor1, $bgcolor2;
$tplname = 'viewqueries';
$dbc = new dataBase();
$i = 0;
$content = '';
//$rs = sql("SELECT `id`, `name` FROM `queries` WHERE `user_id`='&1' ORDER BY `name` ASC", $usr['userid']);
$query = "SELECT id, name FROM `queries` WHERE `user_id`=:1 ORDER BY `name` ASC";
$dbc->multiVariableQuery($query, $usr['userid']);
if ($dbc->rowCount() != 0) {
//while ($r = sql_fetch_array($rs))
while ($r = $dbc->dbResultFetch()) {
$thisline = $viewquery_line;
$thisline = mb_ereg_replace('{queryname}', htmlspecialchars($r['name'], ENT_COMPAT, 'UTF-8'), $thisline);
$thisline = mb_ereg_replace('{queryid}', htmlspecialchars($r['id'], ENT_COMPAT, 'UTF-8'), $thisline);
if ($i % 2 == 1) {
$thisline = mb_ereg_replace('{bgcolor}', $bgcolor2, $thisline);
} else {
$thisline = mb_ereg_replace('{bgcolor}', $bgcolor1, $thisline);
}
$content .= $thisline;
$i++;
}
//mysql_free_result($rs);
} else {
$content = $noqueries;
}
unset($dbc);
tpl_set_var('queries', $content);
tpl_BuildTemplate();
exit;
}
示例7: translit
function translit($input_string)
{
$trans = array();
$ch1 = "/\r\n-абвгдеёзийклмнопрстуфхцыэАБВГДЕЁЗИЙКЛМНОПРСТУФХЦЫЭABCDEFGHIJKLMNOPQRSTUVWXYZ";
$ch2 = " abvgdeeziyklmnoprstufhcyeabvgdeeziyklmnoprstufhcyeabcdefghijklmnopqrstuvwxyz";
for ($i = 0; $i < mb_strlen($ch1); $i++) {
$trans[mb_substr($ch1, $i, 1)] = mb_substr($ch2, $i, 1);
}
$trans["Ж"] = "zh";
$trans["ж"] = "zh";
$trans["Ч"] = "ch";
$trans["ч"] = "ch";
$trans["Ш"] = "sh";
$trans["ш"] = "sh";
$trans["Щ"] = "sch";
$trans["щ"] = "sch";
$trans["Ъ"] = "";
$trans["ъ"] = "";
$trans["Ь"] = "";
$trans["ь"] = "";
$trans["Ю"] = "yu";
$trans["ю"] = "yu";
$trans["Я"] = "ya";
$trans["я"] = "ya";
$trans["\\\\"] = " ";
$trans["[^\\. a-z0-9]"] = " ";
$trans["^[ ]+|[ ]+\$"] = "";
$trans["[ ]+"] = "_";
foreach ($trans as $from => $to) {
$input_string = mb_ereg_replace(str_replace("\\", "\\", $from), $to, $input_string);
}
return $input_string;
}
示例8: do_url
function do_url()
{
if (!keys_exists(Vars::$post, 'num', 'type', 'pagename')) {
throw new PluginException('パラメータが足りません。', $this);
}
if (trim(Vars::$post['text']) == '') {
redirect(Page::getinstance(Vars::$post['pagename']));
}
$page = Page::getinstance(Vars::$post['pagename']);
$source = explode("\n", Page::getinstance(Vars::$post['pagename'])->getsource());
$count = 0;
for ($i = 0; $i < count($source); $i++) {
if (mb_ereg('^#comment(?:\\s|\\(|{|$)', $source[$i])) {
if ($count == Vars::$post['num']) {
$name = trim(Vars::$post['name']);
$text = mb_ereg_replace('{', '&173;', Vars::$post['text']);
$text = mb_ereg_replace('}', '&175;', $text);
$time = date('Y-m-d H:i:s', time());
$str = ":[[{$name}>UserPage/{$name}]] &size(80%) {{$time}}:";
$str .= mb_ereg("\n", $str) ? "\n#block{{$text}}" : " {$text}";
$n = $i + (Vars::$post['type'] == 'below' ? 1 : 0);
array_splice($source, $n, 0, $str);
$page->write(join("\n", $source));
setcookie('name', $name, time() + 60 * 60 * 24 * 30);
redirect($page);
}
$count++;
}
}
$ret['title'] = 'error';
$smarty = $this->getSmarty();
$smarty->assign('text', Vars::$post['text']);
$ret['body'] = $smarty->fetch('error.tpl.htm');
return $ret;
}
示例9: setBusyHours
public function setBusyHours($value)
{
$schedule = mb_strtolower($value);
try {
if (mb_strpos($schedule, '(')) {
$schedule = trim(mb_ereg_replace('\\(.*\\)', '', $schedule));
}
mb_ereg_search_init($schedule);
if (mb_ereg_search('[а-я]\\:')) {
$schedule = mb_ereg_replace('^[\\w-]+\\:', '', $schedule);
$schedule = mb_ereg_replace(', [\\w-]+\\:', ',', $schedule);
}
$schedule = trim($schedule);
$dayIntervals = explode(',', $schedule);
foreach ($dayIntervals as $dayInterval) {
$dayInterval = trim($dayInterval);
if (mb_strpos($dayInterval, 'обед') === false) {
$this->parseDayInterval($dayInterval);
} else {
list($trash, $time) = explode(' ', $dayInterval);
$this->parseLunch($time);
}
}
foreach ($this->schedule as $day => &$workingTime) {
if (isset($workingTime['from'])) {
$workingTime = [$workingTime];
}
}
} catch (\Exception $e) {
$this->schedule = 'error parsing';
}
}
示例10: convInt
public function convInt($arg)
{
// 全角数字や他文字を半角数字に変換
// mb_convert_kana($arg, 'a', 'UTF-8') 全角数字を半角数字に
// mb_ereg_replace('[^0-9]', '', foo) 半角数字以外を削除
return mb_ereg_replace('[^0-9]', '', mb_convert_kana($arg, 'a', 'UTF-8'));
}
示例11: viewqueries
function viewqueries()
{
global $tplname, $usr;
global $viewquery_line, $noqueries, $bgcolor1, $bgcolor2;
$tplname = 'viewqueries';
$dbc = OcDb::instance();
$i = 0;
$content = '';
$query = "SELECT id, name FROM `queries` WHERE `user_id`=:1 ORDER BY `name` ASC";
$s = $dbc->multiVariableQuery($query, $usr['userid']);
if ($dbc->rowCount($s) != 0) {
while ($r = $dbc->dbResultFetch($s)) {
$thisline = $viewquery_line;
$thisline = mb_ereg_replace('{queryname}', htmlspecialchars($r['name'], ENT_COMPAT, 'UTF-8'), $thisline);
$thisline = mb_ereg_replace('{queryid}', htmlspecialchars($r['id'], ENT_COMPAT, 'UTF-8'), $thisline);
if ($i % 2 == 1) {
$thisline = mb_ereg_replace('{bgcolor}', $bgcolor2, $thisline);
} else {
$thisline = mb_ereg_replace('{bgcolor}', $bgcolor1, $thisline);
}
$content .= $thisline;
$i++;
}
} else {
$content = $noqueries;
}
unset($dbc);
tpl_set_var('queries', $content);
tpl_BuildTemplate();
exit;
}
示例12: strip
public static function strip($str, $left, $right)
{
$qleft = preg_quote($left);
$qright = preg_quote($right);
$pattern = '^\\s*' . $qleft . '\\s*(.*?)\\s*' . $qright . '\\s*$';
return mb_ereg_replace($pattern, '\\1', $str);
}
示例13: do_url
function do_url()
{
if (!keys_exists(Vars::$post, 'base', 'config')) {
throw new PluginException('パラメータが足りません', $this);
}
$source = Page::getinstance(':config/plugin/tracker/' . Vars::$post['config'] . '/page')->getsource();
foreach (Vars::$post as $key => $data) {
if (mb_strpos($key, 'param_') === 0) {
$name = '[' . mb_substr($key, 6) . ']';
$_data = trim($data);
$_data = mb_ereg_replace('\\[', '[', $_data, 'm');
$_data = mb_ereg_replace('\\]', ']', $_data, 'm');
$replace[$name] = $_data;
}
}
$replace['[_date]'] = date('Y-m-d H:i:s');
$replace['[_base]'] = Vars::$post['base'];
foreach ($replace as $name => $data) {
$source = mb_ereg_replace(mb_ereg_quote($name), $data, $source, 'm');
}
$db = DataBase::getinstance();
self::$sqlite_pattern = '^' . mb_ereg_quote(Vars::$post['base']) . '/(\\d+)';
$db->create_aggregate('plugin_tracker_maxnum', array('Plugin_tracker', 'sqlite_maxnum'), array('Plugin_tracker', 'sqlite_maxnum_finalize'), 1);
$row = $db->fetch($db->query("SELECT plugin_tracker_maxnum(pagename) FROM page"));
$num = $row[0] + 1;
$title = isset(Vars::$post['param_title']) && trim(Vars::$post['param_title']) != '' ? '/' . trim(Vars::$post['param_title']) : '';
$page = Page::getinstance(Vars::$post['base'] . '/' . $num . $title);
$page->write($source);
redirect($page);
}
示例14: canonizeString
public static function canonizeString($tagTitle, $replacementStr = '-', $allowNonWordChars = '', $reallyRemoveOtherChars = false)
{
$char_map = array('À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'AE', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ð' => 'D', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ő' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ű' => 'U', 'Ý' => 'Y', 'Þ' => 'TH', 'ß' => 'ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'ae', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'd', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ő' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'ű' => 'u', 'ý' => 'y', 'þ' => 'th', 'ÿ' => 'y', '©' => '(c)', 'Α' => 'A', 'Β' => 'B', 'Γ' => 'G', 'Δ' => 'D', 'Ε' => 'E', 'Ζ' => 'Z', 'Η' => 'H', 'Θ' => '8', 'Ι' => 'I', 'Κ' => 'K', 'Λ' => 'L', 'Μ' => 'M', 'Ν' => 'N', 'Ξ' => '3', 'Ο' => 'O', 'Π' => 'P', 'Ρ' => 'R', 'Σ' => 'S', 'Τ' => 'T', 'Υ' => 'Y', 'Φ' => 'F', 'Χ' => 'X', 'Ψ' => 'PS', 'Ω' => 'W', 'Ά' => 'A', 'Έ' => 'E', 'Ί' => 'I', 'Ό' => 'O', 'Ύ' => 'Y', 'Ή' => 'H', 'Ώ' => 'W', 'Ϊ' => 'I', 'Ϋ' => 'Y', 'α' => 'a', 'β' => 'b', 'γ' => 'g', 'δ' => 'd', 'ε' => 'e', 'ζ' => 'z', 'η' => 'h', 'θ' => '8', 'ι' => 'i', 'κ' => 'k', 'λ' => 'l', 'μ' => 'm', 'ν' => 'n', 'ξ' => '3', 'ο' => 'o', 'π' => 'p', 'ρ' => 'r', 'σ' => 's', 'τ' => 't', 'υ' => 'y', 'φ' => 'f', 'χ' => 'x', 'ψ' => 'ps', 'ω' => 'w', 'ά' => 'a', 'έ' => 'e', 'ί' => 'i', 'ό' => 'o', 'ύ' => 'y', 'ή' => 'h', 'ώ' => 'w', 'ς' => 's', 'ϊ' => 'i', 'ΰ' => 'y', 'ϋ' => 'y', 'ΐ' => 'i', 'Ş' => 'S', 'İ' => 'I', 'Ç' => 'C', 'Ü' => 'U', 'Ö' => 'O', 'Ğ' => 'G', 'ş' => 's', 'ı' => 'i', 'ç' => 'c', 'ü' => 'u', 'ö' => 'o', 'ğ' => 'g', 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'Yo', 'Ж' => 'Zh', 'З' => 'Z', 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sh', 'Ъ' => '', 'Ы' => 'Y', 'Ь' => '', 'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya', 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sh', 'ъ' => '', 'ы' => 'y', 'ь' => '', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', 'Є' => 'Ye', 'І' => 'I', 'Ї' => 'Yi', 'Ґ' => 'G', 'є' => 'ye', 'і' => 'i', 'ї' => 'yi', 'ґ' => 'g', 'Č' => 'C', 'Ď' => 'D', 'Ě' => 'E', 'Ň' => 'N', 'Ř' => 'R', 'Š' => 'S', 'Ť' => 'T', 'Ů' => 'U', 'Ž' => 'Z', 'č' => 'c', 'ď' => 'd', 'ě' => 'e', 'ň' => 'n', 'ř' => 'r', 'š' => 's', 'ť' => 't', 'ů' => 'u', 'ž' => 'z', 'Ą' => 'A', 'Ć' => 'C', 'Ę' => 'e', 'Ł' => 'L', 'Ń' => 'N', 'Ó' => 'o', 'Ś' => 'S', 'Ź' => 'Z', 'Ż' => 'Z', 'ą' => 'a', 'ć' => 'c', 'ę' => 'e', 'ł' => 'l', 'ń' => 'n', 'ó' => 'o', 'ś' => 's', 'ź' => 'z', 'ż' => 'z', 'Ā' => 'A', 'Č' => 'C', 'Ē' => 'E', 'Ģ' => 'G', 'Ī' => 'i', 'Ķ' => 'k', 'Ļ' => 'L', 'Ņ' => 'N', 'Š' => 'S', 'Ū' => 'u', 'Ž' => 'Z', 'ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n', 'š' => 's', 'ū' => 'u', 'ž' => 'z', 'Ą' => 'A', 'Ę' => 'E', 'Ė' => 'E', 'Į' => 'I', 'Ų' => 'U', 'ą' => 'a', 'ę' => 'e', 'ė' => 'e', 'į' => 'i', 'ų' => 'u', 'ɗ' => 'd', 'ə' => 'e', 'ʍ' => 'm', 'ş' => 's', 'ţ' => 't', 'Ɗ' => 'D', 'Ə' => 'E', 'Ş' => 'S', 'Ţ' => 'T');
$tagTitle = str_replace(array_keys($char_map), $char_map, $tagTitle);
// replace all other characters with the replacement string
if ($reallyRemoveOtherChars) {
$tagTitle = preg_replace('/([^a-zA-Z0-9' . $allowNonWordChars . '])+/', $replacementStr, $tagTitle);
} else {
$tagTitle = mb_ereg_replace("[^\\w{$allowNonWordChars}]", $replacementStr, $tagTitle);
}
//no duplicates
$tagTitle = mb_ereg_replace("[{$replacementStr}]{2,}", $replacementStr, $tagTitle);
// convert .- to .
$tagTitle = str_replace('.' . $replacementStr, '.', $tagTitle);
// remove . from the beinning and the end
if (mb_substr($tagTitle, 0, 1) == '.') {
$tagTitle = mb_substr($tagTitle, 1);
}
if (mb_substr($tagTitle, mb_strlen($tagTitle) - 1, 1) == '.') {
$tagTitle = mb_substr($tagTitle, 0, mb_strlen($tagTitle) - 1);
}
// remove replacement strings from the beginning and the end
if (mb_substr($tagTitle, 0, 1) == $replacementStr) {
$tagTitle = mb_substr($tagTitle, 1);
}
if (mb_substr($tagTitle, mb_strlen($tagTitle) - 1, 1) == $replacementStr) {
$tagTitle = mb_substr($tagTitle, 0, mb_strlen($tagTitle) - 1);
}
return $tagTitle;
}
示例15: mb_ucfirst
function mb_ucfirst($str, $encoding='UTF-8')
{
$str = mb_ereg_replace('^[\ ]+', '', $str);
$str = mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding).
mb_substr($str, 1, mb_strlen($str), $encoding);
return $str;
}