开发者

Extract values from URls using regular expression

开发者 https://www.devze.com 2023-03-21 09:35 出处:网络
I have the following Pattern http://abc.com/#!/[0-9a-z] http://abc.com/#!/search/%2开发者_StackOverflow社区3[^.]

I have the following Pattern

http://abc.com/#!/[0-9a-z]
http://abc.com/#!/search/%2开发者_StackOverflow社区3[^.]

So the first pattern identify the URL of a user and second URL identifies search parameters.

I can check whether the pattern belongs to user or search query using Pattern and Matcher class in Java. How can i extract the values of user or search term?


You should use capturing group. Look at Java regular expressions: capturing groups for details.

0

精彩评论

暂无评论...
验证码 换一张
取 消