开发者

Find string with RegEx

开发者 https://www.devze.com 2023-03-16 01:50 出处:网络
I want to find a string in text for example Hello World i开发者_Python百科n \"HelloWorld ,hello World,

I want to find a string in text for example Hello World i开发者_Python百科n

"Hello World ,hello World, Hello

World"

I want to replace Hello World with Rock

"Rock ,Rock, Rock"


Using perl

$ perl -pe 'BEGIN{undef $/;} s/[hH]ello.*?World/Rock/smg' input
"Rock ,Rock, Rock

"


echo preg_replace('/[(H|h)ello World]+/','Rock','Hello World ,hello World, Hello World')
0

精彩评论

暂无评论...
验证码 换一张
取 消