正则表达式帮助需要从字符串中提取NFL团队名称

时间:2014-11-06 13:20:02

标签: c# regex string

我需要从类似下面的数据中拉出一串不同字符的NFL团队名称:

  

&安培; nfl_s_delay = 120安培; nfl_s_stamp = 1106052247&安培; nfl_s_left1 =克利夫兰%20AT%20Cincinnati%20(8:25%20PM%20ET)及nfl_s_right1_count = 0&安培; nfl_s_url1 = http://sports.espn.go.com/nfl/preview?gameId=400554328&nfl_s_left2=Kansas%20City%20at%20Buffalo%20(1:00%20PM%20ET)&nfl_s_right2_count=0&nfl_s_url2=http://sports.espn.go.com/nfl/preview?gameId=400554332&nfl_s_left3=Miami%20at%20Detroit%20(1:00%20PM%20ET)&nfl_s_right3_count=0&nfl_s_url3=http://sports.espn.go.com/nfl/preview?gameId=400554355&nfl_s_left4=Dallas%20at%20Jacksonville%20(1:00%20PM%20ET)&nfl_s_right4_count=0&nfl_s_url4=http://sports.espn.go.com/nfl/preview?gameId=400554358&nfl_s_left5=San%20Francisco%20at%20New%20Orleans%20(1:00%20PM%20ET)&nfl_s_right5_count=0&nfl_s_url5=http://sports.espn.go.com/nfl/preview?gameId=400554362&nfl_s_left6=Tennessee%20at%20Baltimore%20(1:00%20PM%20ET)&nfl_s_right6_count=0&nfl_s_url6=http://sports.espn.go.com/nfl/preview?gameId=400554367&nfl_s_left7=Pittsburgh%20at%20NY%20Jets%20(1:00%20PM%20ET)&nfl_s_right7_count=0&nfl_s_url7=http://sports.espn.go.com/nfl/preview?gameId=400554370&nfl_s_left8=Atlanta%20at%20Tampa%20Bay%20(1:00%20PM%20ET)&nfl_s_right8_count=0&nfl_s_url8=http://sports.espn.go.com/nfl/preview?gameId=400554372&nfl_s_left9=Denver%20at%20Oakland%20(4:05%20PM%20ET)&nfl_s_right9_count=0&nfl_s_url9=http://sports.espn.go.com/nfl/preview?gameId=400554396&nfl_s_left10=St.%20Louis%20at%20Arizona%20(4:25%20PM%20ET)&nfl_s_right10_count=0&nfl_s_url10=http://sports.espn.go.com/nfl/preview?gameId=400554397&nfl_s_left11=NY%20Giants%20at%20Seattle%20(4:25%20PM%20ET)&nfl_s_right11_count=0&nfl_s_url11=http://sports.espn.go.com/nfl/preview?gameId=400554400&nfl_s_left12=Chicago%20at%20Green%20Bay%20(8:30%20PM%20ET)&nfl_s_right12_count=0&nfl_s_url12=http://sports.espn.go.com/nfl/preview?gameId=400554403&nfl_s_left13=Carolina%20at%20Philadelphia%20(8:30%20PM%20ET)&nfl_s_right13_count=0&nfl_s_url13=http://sports.espn.go.com/nfl/preview?gameId=400554408&nfl_s_count=13&nfl_s_loaded=true

我尝试过这种模式:

string pattern = @"[^A-Za-z]";

然而,它不会返回我需要的东西。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

(=[A-Z])(\w|\%20|\.)+

这将仅捕获团队名称和他们之间的空格字符,使用前导" ="。然后你可以替换"%20"用" "并将结果字符串拆分为" ="所以你有一个字符串列表,每个字符串都是一个团队名称。至少,这是我在Python中所做的。不确定您可以使用哪些方法。