Loading...

使用javascript 正規化判斷網址url是否正確

Temperature: 0 °C

Mark ChangMark Chang
author_tools

使用javascript判斷網址url是否正確

正規化方式如下:

 var str = URL;
//判斷網址的正規化表示方式:http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
var Expression = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
var objExp = new RegExp(Expression);
if (objExp.test(str) == true) {
return true;//如果正確
} else {
return false;//如果不正確
}

 

#故事  #判斷網址url是否正確  #javascript  
https://innstory.com/story-使用javascript_正規化判斷網址url是否正確-2888
javascript

Prev
 使用_Closure_Compiler_幫_javascript_瘦身

Next
使用手機將網址分享到_Line時如何強制使用預設外部瀏覽器開啟 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

分享 紓壓小物-熱熔槍3D筆 | 鄭永銘老師的Blog

分享 紓壓小物-熱熔槍3D筆...

這個挺有趣的,看來之前買錯的熱熔槍終於有用處了!! 只是有沒有那麼好的藝術天分又是另外一個課題了@@...

分享 猴子自拍照爭議落幕了,美上訴法院:猴子沒有著作權

分享 猴子自拍照爭議落幕了,...

總之,全都是人搞出來的。 而牽扯到人的問題永遠都是複雜。

使用html2canvas截圖將背景顏色更改為白色

使用html2canvas截...

在Javascript裡,我們可以使用htmlcanvas來將網頁畫面的某個區塊截圖下來存檔。 運用...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format