开发者

php grep exec or system regex

开发者 https://www.devze.com 2023-01-23 22:18 出处:网络
How can I grep a pattern that can include spaces, commas etc using exec or system in PHP, and return one string separated by a comma each result. If needed, I can make use of awk or sed to separated b

How can I grep a pattern that can include spaces, commas etc using exec or system in PHP, and return one string separated by a comma each result. If needed, I can make use of awk or sed to separated by comma.

So for instance, if the pattern to se开发者_运维知识库arch is: hello worl then return:

$result = 'hello world, hello worlds, hello worldy';

Any ideas will be appreciated. Thanks


Check out escapeshellarg() and escapeshellcmd().

Edit:

Is this in just one file? If you're not searching across the system then just use the built-in functions, they'll be plenty fast.

0

精彩评论

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