当前位置: 动力学知识库 > 问答 > 编程问答 >

PHP CSV regex in string

问题描述:

I have a csv file.

In this, I have a bad character : arr‰t. I would this "arret"

I test this : $bodytag = str_replace("‰", "e",$content); doesn't work.

So I search a query which I say : find a word start with "arr" and end with "t" and remplace all the string by "arret".

I find a function to get content between but I can't do my query.

 function str_between($str,$start,$end) {

if (preg_match_all('/' . preg_quote($start) . '(.*?)' . preg_quote($end) . '/',$str,$matches)) {

return $matches[1];

}

// no matches

return false;

}

Can you help me?

网友答案:

Did you try preg_replace('/‰/', 'e', $string); ? It works for me, with the string "arr‰t", preg_replace returns me "arret"

网友答案:

My 2 cents: Your file might have encoded characters not supported by the doctype specified. Arret in French has a small "hat" over top of the "e", as in "ê". Check to see if that can be searched and/or replaced as/with ê or ê

分享给朋友:
您可能感兴趣的文章:
随机阅读: