2014-11-06 78 views
-4

拉NFL球隊的名字,我需要從不同的字符的字符串從數據拉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]"; 

然而,它不會返回我所需要的。任何幫助,將不勝感激。

+0

你的正則表達式正在尋找一個非字母字符。你需要指定你想要找到的東西。 – 2014-11-06 13:22:49

+2

你真的嘗試過嗎?這個正則表達式對此沒有意義。 – Jonesopolis 2014-11-06 13:25:22

+0

你真的應該做一個誠實的嘗試,否則你只是要求人們爲你做這一切。 – 2014-11-06 13:26:35

回答

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

這將只捕獲團隊名稱和它們之間的空格字符,並帶前導「=」。然後你可以用「」替換「%20」,並將結果字符串分割成「=」,這樣你就可以得到一個字符串列表,每個字符串都是一個團隊名稱。至少,這是我在Python中所做的。不知道有什麼方法可供您使用。

+0

謝謝你的幫助.....在正則表達式新的進出口,並不確定它是如何工作的...非常混亂的新手.....在你的幫助下,我能夠寫一個方法來獲取數據我需要.... – SuncoastOwner 2014-11-06 15:21:01