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

分享 壞處多過好處,蘋果共同創辦人Steve Wozniak要脫離臉書了!

分享 壞處多過好處,蘋果共同...

覺得使用了一個社群平台,對個人來說就像是使用了一個關於社交或社群的工具,你無法保證每個人的使用心態是...

分享 刺激銷量? 市場再傳蘋果計畫推出紅色款 iPhone X - 手機新聞 | ePrice 比價王

分享 刺激銷量? 市場再傳蘋...

紅蘋果都要出來了...意思是說以後還有可能有青蘋果嗎? 所以光用顏色就可以刺激到銷量~果然....人...

使用javascript判斷網頁編輯器ckeditor是否有輸入內容

使用javascript判斷...

如主題想要使用javascript判斷網頁編輯器ckor是否有輸入內容。 var str = CKE...

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