Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何匹配文本周围的所有符号_Php - Fatal编程技术网

Php 如何匹配文本周围的所有符号

Php 如何匹配文本周围的所有符号,php,Php,这里我只得到文本的匹配,但是如何匹配文本中存在或不存在的所有符号?这将匹配所有符号: $text = '2434__(this is something)-__2345'; preg_match('/[\p{Latin}]+/u', text, $matches); 我希望你能明白你想要什么 $match = $text 你想匹配文本的哪一部分?我想匹配文本周围,字母周围可能出现的所有符号,包括大括号、斜线和其他符号我有这个文本“一些文本”-我匹配它,但如果有其他符号我错过了它们,所以我

这里我只得到文本的匹配,但是如何匹配文本中存在或不存在的所有符号?

这将匹配所有符号:

$text = '2434__(this is something)-__2345';

 preg_match('/[\p{Latin}]+/u', text, $matches);

我希望你能明白你想要什么

$match = $text

你想匹配文本的哪一部分?我想匹配文本周围,字母周围可能出现的所有符号,包括大括号、斜线和其他符号我有这个文本“一些文本”-我匹配它,但如果有其他符号我错过了它们,所以我想匹配它们你的意思是什么?前缀和sufix或文本前后?文本前后,“开始文本一些空格结束文本”,所有这些都是我想要匹配的前后内容
preg_match('/^([^\p{Latin}]+)([\p{Latin}\s]*)([^\p{Latin}]+)$/u', $text, $matches);

print_r($matches);