ereg-replace

replace ereg_replace with preg_replace [duplicate]

…衆ロ難τιáo~ 提交于 2020-01-09 04:56:46
问题 This question already has answers here : How can I convert ereg expressions to preg in PHP? (4 answers) Closed 7 months ago . Hi need to change the function ereg_replace("[\]", "", $theData) to preg_replace 回答1: To port ereg_replace to preg_replace you need to put the regex between a pair of delimiter Also your regx is [\] is invalid to be used for preg_replace as the \ is escaping the closing char class ] The correct port is preg_replace('/[\\\]/','',$theData) Also since the char class has

ereg_replace, preg_replace and PHP 5.3.0 [duplicate]

我只是一个虾纸丫 提交于 2020-01-06 05:39:06
问题 This question already has answers here : Closed 8 years ago . Possible Duplicates: Changing ereg_replace to equivalent preg_replace Converting ereg expressions to preg Can anyone show me the equivalent of : ereg_replace("\n#[^\n]*\n", "\n", $sql) in preg_replace Thanks 回答1: All you need in this case is delimiters (here / ): preg_replace("/\n#[^\n]*\n/", "\n", $sql) Also read about the difference of PCRE from POSIX. 回答2: preg_replace("~\n#[^\n]*\n~", "\n", $sql); 来源: https://stackoverflow.com

Replace all characters except letters, numbers, spaces and underscores [closed]

瘦欲@ 提交于 2019-12-18 10:32:37
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I am looking to replace all characters in a string except letters, numbers, spaces and underscores. Could someone please provide a example? 回答1: I normally use something like: $string = preg_replace("/[^ \w]+/", "", $string); That replaces all non-space and non-word characters with

Replace all characters except letters, numbers, spaces and underscores [closed]

不羁的心 提交于 2019-11-29 22:09:44
I am looking to replace all characters in a string except letters, numbers, spaces and underscores. Could someone please provide a example? I normally use something like: $string = preg_replace("/[^ \w]+/", "", $string); That replaces all non-space and non-word characters with nothing. Raffael [^0-9a-zA-Z_\s] is what you want to replace. <?php $string = 'April 15, 2003'; $pattern = '/[^\w ]+/'; $replacement = ''; echo preg_replace($pattern, $replacement, $string); ?> 来源: https://stackoverflow.com/questions/6442174/replace-all-characters-except-letters-numbers-spaces-and-underscores

PHP ereg_replace deprecated [duplicate]

北战南征 提交于 2019-11-28 02:02:11
This question already has an answer here: How can I convert ereg expressions to preg in PHP? 4 answers I have a script that throws me errors because I run PHP 5.3.1 What Do I have to use in the example? $row[$j] = ereg_replace("\n", "\\n", $row[$j]); Deprecated: Function ereg_replace() is deprecated in.. Use preg_replace instead, just add delimiters . $row[$j] = preg_replace("#\n#", "\\n", $row[$j]); Use the preg_replace function instead. 来源: https://stackoverflow.com/questions/4226107/php-ereg-replace-deprecated

replace ereg_replace with preg_replace [duplicate]

强颜欢笑 提交于 2019-11-27 13:45:32
This question already has an answer here: How can I convert ereg expressions to preg in PHP? 4 answers Hi need to change the function ereg_replace("[\]", "", $theData) to preg_replace To port ereg_replace to preg_replace you need to put the regex between a pair of delimiter Also your regx is [\] is invalid to be used for preg_replace as the \ is escaping the closing char class ] The correct port is preg_replace('/[\\\]/','',$theData) Also since the char class has just one char there is no real need of char class you can just say: preg_replace('/\\\/','',$theData) Since you are replace just a

PHP ereg_replace deprecated [duplicate]

走远了吗. 提交于 2019-11-26 22:04:56
问题 This question already has answers here : How can I convert ereg expressions to preg in PHP? (4 answers) Closed 6 months ago . I have a script that throws me errors because I run PHP 5.3.1 What Do I have to use in the example? $row[$j] = ereg_replace("\n", "\\n", $row[$j]); Deprecated: Function ereg_replace() is deprecated in.. 回答1: Use preg_replace instead, just add delimiters. $row[$j] = preg_replace("#\n#", "\\n", $row[$j]); 回答2: Use the preg_replace function instead. 来源: https:/

php Replacing multiple spaces with a single space [duplicate]

时光怂恿深爱的人放手 提交于 2019-11-26 03:04:29
问题 This question already has answers here : How can I convert ereg expressions to preg in PHP? (4 answers) Closed 6 months ago . I\'m trying to replace multiple spaces with a single space. When I use ereg_replace , I get an error about it being deprecated. ereg_replace(\"[ \\t\\n\\r]+\", \" \", $string); Is there an identical replacement for it. I need to replace multiple \" \" white spaces and multiple nbsp white spaces with a single white space. 回答1: Use preg_replace() and instead of [ \t\n\r]