Hi need to change the function ereg_replace("[\]", "", $theData)
to preg_replace
您需要将函数ereg_replace(“[\]”,“”,$ theData)更改为preg_replace
4 个解决方案
#1
21
To port ereg_replace
to preg_replace
you need to put the regex between a pair of delimiter
要将ereg_replace移植到preg_replace,您需要将正则表达式放在一对分隔符之间
Also your regx is [\]
is invalid to be used for preg_replace as the \
is escaping the closing char class ]
另外你的regx [\]无法用于preg_replace,因为\正在逃避关闭的char类]
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:
此外,因为char类只有一个char,所以不需要char类,你只需说:
preg_replace('/\\\/','',$theData)
Since you are replace just a single char, using regex for this is not recommended. You should be using a simple text replacement using str_replace
as:
由于您只更换一个char,因此不建议使用正则表达式。您应该使用str_replace使用简单的文本替换:
str_replace('\\','',$data);
#2
2
str_replace("\\","",$theData);
But I seriously doubt you need that replace at all. most likely you need some other operation.
What is this replace for?
但我严重怀疑你需要替换它。你很可能需要一些其他的操作。这个替换是什么?
#3
0
preg_replace("/\\\/", "", $theData);
#4
0
I used this sed to automatically replace ereg_replace by preg_replace and put the required slashes in. Assumes no \" in the first regex
我使用这个sed自动替换preg_replace的ereg_replace并将所需的斜杠放入。假设在第一个正则表达式中没有\“
sed -i 's#ereg_replace("\([^"]*\)"#preg_replace("/\1/"#g' *.php
#1
21
To port ereg_replace
to preg_replace
you need to put the regex between a pair of delimiter
要将ereg_replace移植到preg_replace,您需要将正则表达式放在一对分隔符之间
Also your regx is [\]
is invalid to be used for preg_replace as the \
is escaping the closing char class ]
另外你的regx [\]无法用于preg_replace,因为\正在逃避关闭的char类]
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:
此外,因为char类只有一个char,所以不需要char类,你只需说:
preg_replace('/\\\/','',$theData)
Since you are replace just a single char, using regex for this is not recommended. You should be using a simple text replacement using str_replace
as:
由于您只更换一个char,因此不建议使用正则表达式。您应该使用str_replace使用简单的文本替换:
str_replace('\\','',$data);
#2
2
str_replace("\\","",$theData);
But I seriously doubt you need that replace at all. most likely you need some other operation.
What is this replace for?
但我严重怀疑你需要替换它。你很可能需要一些其他的操作。这个替换是什么?
#3
0
preg_replace("/\\\/", "", $theData);
#4
0
I used this sed to automatically replace ereg_replace by preg_replace and put the required slashes in. Assumes no \" in the first regex
我使用这个sed自动替换preg_replace的ereg_replace并将所需的斜杠放入。假设在第一个正则表达式中没有\“
sed -i 's#ereg_replace("\([^"]*\)"#preg_replace("/\1/"#g' *.php