简体   繁体   中英

Extract values from URls using regular expression

I have the following Pattern

http://abc.com/#!/[0-9a-z]
http://abc.com/#!/search/%23[^.]

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM