For example: from the following string
Opening Hours: 11:30-21:30 Modified category Tags: wireless Internet access (8) can swipe (7) Friends (5) Family Gatherings (5) Business Dinners (4) Couples (4) Bring your own drinks (2 )
Acquired in: 11:30-21:30
Two digits: two digits-two digits: two digits therefore the regular expression:\\d{2}:\\d{2}-\\d{2}:\\d{2}
The specific code is as follows:
Import Java.util.regex.matcher;import Java.util.regex.pattern;public class Regularexpressiontest {public static void Main (string[] args) {String str = "Business Hours: 11:30-21:30 Modify Category Tags: wireless Internet access (8) can swipe (7) Friends (5) Family Gatherings (5) business Banquets (4) Couples (4) can bring their own drinks (2)";
pattern p=pattern.compile ("\\d{2}:\\d{2}-\\d{2}:\\d{2}"); Matcher M=p.matcher (str); while (M.find ()) { System.out.println (M.group ()); } }}
Regular Expressions Detailed description: Http://baike.baidu.com/link?url=MZFseIpJwMYqeNU9Zpkj10371l6GvPBZAj_wSzbwTLgduo_ 70m0docsvytiatkpjhu7znjzpazfmtqlkst_via
JAVA Regular Expression intercept string small example