87,994
社区成员
发帖
与我相关
我的任务
分享string test = " 编剧:<M>彭浩翔<br/>主演:<M>古天乐 \\ <W>张钰 \\ <W>陈慧琳<br/>";
Regex reg = new Regex(@"(?i)主演:(?:<[MW]>\s*([^\s\\<]+)\s*\\?\s*)+");
Match m = reg.Match(test);
if (m.Success)
{
foreach (Capture c in m.Groups[1].Captures)
{
richTextBox2.Text += c.Value + "\n";
}
}
<script type="text/javascript">
<!--
var str = "编剧:<M>彭浩翔<br/>主编:<M>古天乐 \ <W>张钰 \ <W>陈慧琳<br/>";
var re1 = /主编:(<[MW]>([^MW<>\\]+))+/;
var arr = str.match(re1);
alert(arr[0].replace("主编:","").replace(/<[MW]>/g,""));
//-->
</script>
<script type="text/javascript">
<!--
var str = "编剧:<M>彭浩翔<br/>主编:<M>古天乐 \ <W>张钰 \ <W>陈慧琳<br/>";
var re = /<[MW]>([^MW<>\\]+)/g;
var re1 = /主编:(<[MW]>([^MW<>\\]+))+/;
var str1 = str.match(re1)[0];
var arr = str1.match(re);
for(var i = 0 ; i < arr.length; i++){
alert(arr[i].replace(/<[MW]>/,""))
}
//-->
</script>
<script type="text/javascript">
var data = "编剧:<M>彭浩翔<br/>主演:<M>古天乐 \ <W>张钰 \ <W>陈慧琳<br/>";
var reg1 = /主演:(.*?)(<\/?br[^>]*>|$)/ig;
var reg2 = /<[^>]*>|\\/g;
if(reg1.test(data))
{
alert(RegExp.$1.replace(reg2, ""));
}
</script><script>
var str = "编剧:<M>彭浩翔<br/>主编:<M>古天乐 \ <W>张钰 \ <W>陈慧琳<br/>";
var index = str.indexOf("主编");
str = str.substring(index, str.length);
var reg = /[\u4E00-\u9FA5]{2,4}/g;
str = str.match(reg);
str = str.join("、");
str = str.substring(0, 2) + ":" + str.substring(3, str.length);
alert(str);
</script>