這解釋了它在做什麼。
要修改,取決於你想要做什麼。
這是其目前在做什麼 -
# ^(?=.*?bear\ grylls)(?=.*?(\bnbc\b|reality|episode|show|watch|series|season|premiere)).*?
^ # Beginning of string
(?= # Look ahead
.*? # Ungreedy, any number of characters
bear\ grylls # Must be 'bear grylls' somewhere
) # End lookahead
(?= # Look ahead
.*? # Ungreedy, any number of characters
( # (1 start), Must be one of these somewhere
\b nbc \b
| reality
| episode
| show
| watch
| series
| season
| premiere
) # (1 end)
) # End lookahead
.*? # Assertions passed tests, now match the entire string
我將其修改爲這個獲得一個更好一點的功能 -
# (?s)^(?=.*\bbear\ grylls\b)(?=.*\b(nbc|reality|episode|show|watch|series|season|premiere)\b).*
(?s) # Dot all modifier
^ # Beginning of string
(?= # Look ahead
.* # Greedy, any number of characters
\b bear\ grylls \b # Must be 'bear grylls'
) # End lookahead
(?= # Look ahead
.* # Greedy, any number of characters
\b
( # (1 start), Must be one of these
nbc
| reality
| episode
| show
| watch
| series
| season
| premiere
) # (1 end)
\b
) # End lookahead
.* # Assertions passed tests, now match the entire string
我建議使用RegexFormat 5它格式化,並創建自動評論。
來源
2014-10-09 02:36:47
sln
看看http://regex101.com,這給你輸入正則表達式的正確解釋 – radar 2014-10-09 02:03:31