Preg_Mach_All如何消除结尾字符
Preg_Mach_All How To Eliminate the Ending Characters
我喜欢preg_mach_all
命令,但现在我遇到了这种情况:
$lotes_fil='/((?:https?|http?):\/\/(?:\S*?\.\S*?)(?:[\s)\[\]{};"\'<]|\.\s|$))/';
preg_match_all($lotes_fil,$rs,$link_pre, PREG_SET_ORDER);
输出是这样的:
[0] => Array
(
[0] => https://s3.amazonaws.com/mesena.com/vodcategories/58e1a299dca3c3a22fbd8319/iconPng-1576021669572.png"
[1] => https://s3.amazonaws.com/mesena.com/vodcategories/58e1a299dca3c3a22fbd8319/iconPng-1576021669572.png"
)
[1] => Array
(
[0] => https://images.mesena.com/assets/images/default/vodcategory.id-imageFeatured.jpg"
[1] => https://images.mesena.com/assets/images/default/vodcategory.id-imageFeatured.jpg"
)
[2] => Array
(
[0] => https://s3.amazonaws.com/silo.mesena.com/origin/5638f208fbdc021398ae8681/production/202006/19/5638f208fbdc021398ae8681_212-21719"
[1] => https://s3.amazonaws.com/silo.mesena.com/origin/5638f208fbdc021398ae8681/production/202006/19/5638f208fbdc021398ae8681_212-21719"
)
我需要删除最后一个 " 但我想使用这个正则表达式因为对我有用 well.In 原始数据有 " 作为每个 URL
的结尾
谢谢你的帮助。
我会使用:
~https?://[^\s"]+~
解释:
~ # regex delimiter, it allows to use / without escaping
https? # http OR https
:// # literally
[^\s"]+ # 1 or more any character that is not a space or double quote
我喜欢preg_mach_all
命令,但现在我遇到了这种情况:
$lotes_fil='/((?:https?|http?):\/\/(?:\S*?\.\S*?)(?:[\s)\[\]{};"\'<]|\.\s|$))/';
preg_match_all($lotes_fil,$rs,$link_pre, PREG_SET_ORDER);
输出是这样的:
[0] => Array
(
[0] => https://s3.amazonaws.com/mesena.com/vodcategories/58e1a299dca3c3a22fbd8319/iconPng-1576021669572.png"
[1] => https://s3.amazonaws.com/mesena.com/vodcategories/58e1a299dca3c3a22fbd8319/iconPng-1576021669572.png"
)
[1] => Array
(
[0] => https://images.mesena.com/assets/images/default/vodcategory.id-imageFeatured.jpg"
[1] => https://images.mesena.com/assets/images/default/vodcategory.id-imageFeatured.jpg"
)
[2] => Array
(
[0] => https://s3.amazonaws.com/silo.mesena.com/origin/5638f208fbdc021398ae8681/production/202006/19/5638f208fbdc021398ae8681_212-21719"
[1] => https://s3.amazonaws.com/silo.mesena.com/origin/5638f208fbdc021398ae8681/production/202006/19/5638f208fbdc021398ae8681_212-21719"
)
我需要删除最后一个 " 但我想使用这个正则表达式因为对我有用 well.In 原始数据有 " 作为每个 URL
的结尾谢谢你的帮助。
我会使用:
~https?://[^\s"]+~
解释:
~ # regex delimiter, it allows to use / without escaping
https? # http OR https
:// # literally
[^\s"]+ # 1 or more any character that is not a space or double quote