[英]Easiest way to filter out particular values php
I'm trying to filter out everything from key_people until the start of the name "Maynard" in the following string in php: 我正在尝试过滤掉key_people中的所有内容,直到php中以下字符串中名称“ Maynard”的开头:
key_people = https://info.yahoo.com/management-team[[Maynard Webb]] Rest of String key_people = https://info.yahoo.com/management-team[[Maynard Webb]]其他字符串
So that I am left only with: "Maynard Webb Rest of String" 这样,我只剩下:“ Maynard Webb其他字符串”
However I am looking for a generic approach that can be applied to most strings (having a format as shown below) as the string and name within could be be different. 但是,我正在寻找一种通用方法,该方法可以应用于大多数字符串(格式如下所示),因为其中的字符串和名称可能不同。 So in general how to filter out for a string with the generic format: 因此,通常如何过滤出具有通用格式的字符串:
"key_people = Some value[[Name]] Rest of String" “ key_people =某些值[[名称]]字符串的其余部分”
To only return: 仅返回:
"Name Rest of String" “名称字符串的其余部分”
Please assist 请协助
^.*?\[\[|\]\]
Try this.Replace by empty string
.This will work if your format is fixed.See demo. 尝试一下。用empty string
替换。如果您的格式固定,这将起作用。请参见演示。
https://regex101.com/r/rU8yP6/7 https://regex101.com/r/rU8yP6/7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.