2014-01-23 26 views
0

我已經在我的JavaScript了什麼是<和[在正則表達式中?

var $pBracketVisualOpenRegExp = /[/ ; 

var $pBracketFunctionOpenRegExp = /</ ; 

。 但doesent與.match作品()

$MatchArray = $String.match(/</); 

其他支架和標誌{(「工作正常。

+1

嘗試轉義'[',像這樣'\ [' –

+0

http://www.google.com/search?q=regex+cheat+sheet和http://www.google.com/search?q=正則表達式+快速+參考。或任何官方文件。 –

+0

字符<可能是特殊的。它標誌着單詞的開頭。 – Michas

回答

0

/[/是不是一個有效的RegEx。代碼爲/</,它的工作原理。

var $pBracketFunctionOpenRegExp = /</ ; 

$String = 'aaa<lklkd'; 
$MatchArray = $String.match($pBracketFunctionOpenRegExp); //result ['<'] 
0

「\ <」將匹配單詞開始處的空字符串。