且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

简单的Java正则表达式从封装字符串中提取IP地址和端口

更新时间:2022-11-12 09:07:25

([0-9.]*)(\/|:)([0-9]*)

这是正则表达式.第一组给您IP.第三组为您提供端口号.中间组给出分隔符,即/或:用于交替.可以忽略.

Here is the regex . First group gives you IP. Third group gives you the Port number. Middle group gives separator i.e / or : used for alternation. It can be ignored.