C#如何用正則表達式截取https和帶端口的域名

如題。現有代碼如下。只能截取 http://www.baidu.com的 www.baidu.com

當域名為https://www.baidu.com 或者為 http://www.baidu.com:8080 時 則無法正確讀取。。

求高手給去能截取這樣格式的代碼 Thanks!

?

string p = @"http://[^\.]*\.(?<domain>[^\.]*)";Regex reg = new Regex(p, RegexOptions.IgnoreCase);Match m = reg.Match(HostUrl);Result=m.Groups["domain"].Value;
最后自己想到了 (http|https)://(?<domain>[^(:|/]*)
這樣即可謝謝樓上幾位 

?

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/280881.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/280881.shtml
英文地址,請注明出處:http://en.pswp.cn/news/280881.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

推薦一個開源的 .NET 二維碼生成庫

你好&#xff0c;這里是 Dotnet 工具箱&#xff0c;定期分享 Dotnet 有趣&#xff0c;實用的工具和組件&#xff0c;希望對您有用&#xff01;介紹QrCodeGenerator 是開源的 .NET 二維碼生成庫&#xff0c;它支持從文本字符串和字節數組生成二維碼圖片。這個庫是基于 .NET Stan…

vue循環中的v-show

v-show如果使用循環對象的屬性來時控制, 這個屬性必須是加載時就存在的 <div class"list-group col-sm-12" v-for"(issue,index) in issue_list"><a click"switch_comments(issue, index)" style"background-color:#5cb85c;font-w…

C# 圖片畫矩形,添加文字

1.初始設置字體與筆 Pen pen new Pen(Color.FromArgb(220, Color.Green), 5);Font font new Font("微軟雅黑", fontSize, FontStyle.Bold); // 定義字體Brush whiteBrush new SolidBrush(Color.FromArgb(220, Color.Red)); // 畫文字用 2.初始設置圖片和Graphics …

全量更新和增量更新_增量BIOS更新或直接更新到最新版本哪個更好?

全量更新和增量更新There are few things as irritating as a Blue Screen of Death, but sometimes there is an easy fix for it like updating the BIOS for instance. If multiple updates are available though, do you do incremental updates or can you just use the l…

BZOJ4590: [Shoi2015]自動刷題機

【傳送門&#xff1a;BZOJ4590】 簡要題意&#xff1a; 有l秒時間&#xff0c;AC了k道題&#xff0c;給出每秒寫的代碼行數&#xff08;行數>0表示寫&#xff0c;<0表示刪除&#xff0c;如果剩下的行數不夠刪&#xff0c;則為0&#xff09;&#xff0c;假設行數>n時能…

[Office 2010 易寶典]什么是Office Web App?如何在線查看Office文檔?

什么是Office Web App&#xff1f; Office Web App使得Microsoft Office能擴展到網絡瀏覽器上。用戶可以直接在通過瀏覽器在線查看和編輯保存在網站上的文檔。 如何上傳Office文檔&#xff1f; 在Microsoft Word 2010里面&#xff0c;您可以把Word文檔保存到Windows Live SkyDr…

Pipy:保護 Kubernetes 上的應用程序免受 SQL 注入和 XSS 攻擊

注入攻擊在 OWASP Web 應用 10 大安全風險[1] 排名 2021 年下滑至第 3 位&#xff0c;多年來一直位居前十。SQL 注入 (SQLi) 是一種用于攻擊網站和 Web 應用程序的常見注入技術。沒有將用戶輸入與數據庫命令完全分開的應用程序面臨著將惡意輸入作為 SQL 命令執行的風險。成功的…

docker 開啟命令\退出容器

開啟 docker load -i test.tar docker imagesdocker run -it -p 8000:80 test //8000為訪問ip 的端口 80 為test設置的端口 docker rename 原容器名 新容器名訪問IP 為 localhost:8000 退出容器 如果要正常退出不關閉容器&#xff0c; 請按CtrlPQ進行退出容器

如何阻止YouTube在iOS,Android和Web上自動播放視頻

Over at YouTube, they love it when you watch more YouTube. If you’re sick of YouTube automatically queuing up more videos for you, however, it’s easy enough to turn the autoplay feature off and go back to watching your videos at your own pace. 在YouTube上…

(php)thinkphp3.2配置sql_server

(php)thinkphp3.2配置sql_server 標簽&#xff1a; php thinkphp sql_server2016年12月16日 15:20:19631人閱讀 評論(0) 收藏 舉報分類&#xff1a;php&#xff08;18&#xff09; 最近要整一個crm和erp的對接&#xff0c;最坑的是&#xff0c;erp的是用.net寫的&#xff0c;數…

viewData

viewdata[alert]"alert(你好)"<script>viewdata[alert]</script> 在Controller存儲數據 在 界面得到 關于 ViewData和ViewMode 點擊這里 http://wanshiqian1221.blog.163.com/blog/static/6872130420095242016546/

Blog.Core 第四季度開源更新說明書

B/C/V/PAn open-source organization based on .NET/Core and Vue (React/NG) to quickly build MVC & SPA and microservice application.開源貢獻NETCORE架構設計BCVP開發組成員說&#xff1a;BCVP是以Blog.Core為核心框架設計的一整套前后端分離、RBAC與數據鑒權、統一C…

關于HibernateDaoSupport中的getHibernateTemplate().execute及executeFind方法

轉自&#xff1a;https://blog.csdn.net/angus_17/article/details/8501668 1. 這兩個方法都是為了Spring在接管Hibernate之后&#xff0c;可以對HibernateDaoSupport進行靈活的擴展而用的。 二者的主要區別在于&#xff0c;execute返回的是一個Object&#xff0c;而executeFin…

bootstrap筆記

1.整體排版 <div class"container"><div class"row"><div class"col-md-offset-3 col-md-6"><div class"panel panel-primary"><div class"panel-heading"><h3 class"panel-title&q…

如何將聯系人導入Windows聯系人文件夾和從中導出聯系人

In Windows 7 and 8, there is a Contacts folder in your user directory. This folder can be useful if you have your contacts in a single .vcf file and want to move them into a .csv file for importing into programs like Outlook 2013. 在Windows 7和8中&#xff…

【vue】跟著老馬學習vue-數據雙向綁定

學習了node.js教程&#xff0c;只能說是有了一定的了解&#xff0c;之前也了解了webpack和es6的核心內容&#xff0c;也看過vue2.0的官網教程&#xff0c;并結合視頻看過項目&#xff0c;但是理解和運用仍然存在很多問題&#xff0c;接下來的一段時間&#xff0c;跟著老馬學習v…

位運算符2

class TestExer1{public static void main(String[] args){int m 12;int n 5;System.out.println("m:" m " n:" n);//方法一&#xff1a;提供一個臨時變量。//int temp m;// m n;// n temp;//System.out.println("m:" m &…

C# 實例解析事件委托之EventHandler

概述事件屬于委托的一個子集&#xff0c;像我們平時界面上的鼠標點擊按鈕后響應事件、事件的發布和訂閱等都需要用到委托.通過委托可以很好的實現類之間的解耦好。事件委托EventHandler的函數原型如下&#xff1a;delegate 表示這個個委托&#xff0c;事件委托沒有返回值&#…

C# HttpWebRequest post 數據與上傳圖片到server

主體 Dictionary<string, object> postData new Dictionary<string, object>(); string fileFullPath this.imgFullPath;if (!File.Exists(fileFullPath)){Message(Error, "file not exist: " fileFullPath);goto EndGetPost;}// 先定義一個…

多虧了Google相冊,如何一鍵釋放Android手機上的空間

Let’s be real here: modern smartphones have limited storage. While they’re coming with a lot more than they used to, it’s easy to fill 32GB without even realizing it. And with today’s high-end cameras, well, pictures and videos can quickly consume a bi…