所以我有這樣的代碼:正則表達式,如果HTTP或HTTPS字符串中存在
function validateText(str)
{
var tarea = str;
var tarea_regex = /^(http|https)/;
if(tarea_regex.test(String(tarea).toLowerCase()) == true)
{
$('#textVal').val('');
}
}
這完全適用此:
https://hello.com
http://hello.com
但不適用於:
這是一個網站http://hello.com asdasd asdasdas
嘗試做一些閱讀,但我不在哪裏放* *?因爲他們會在任何地方檢查字符串表達式根據這裏 - >http://www.regular-expressions.info/reference.html
謝謝
FWIW,http://gskinner.com/RegExr/是瞭解正則表達式的好方法。 – timrwood