我想匹配任何具有模式的字符串
{"id":"362237-
any number of characters followed by
"http//:www.abc.com"
any number of characters followed by
"id":"364121-
any number of characters followed by
"http://www.efg.com"
我想将上面的模式匹配到下面的字符串。
[{"id":"362237-13","http//:www.abc.com"},{"id":"364075-13","http://www.xyz.com"},{"id":"364121-13","http://www.efg.com"}]
代码:
String pttrn=".*{\"id\":"362237-.*\"http//:www.abc.com\".*\"id\":"364121-.*\"http://www.efg.com\".*";
String mtchr="[{\"id\":\"362237-13\",\"http//:www.abc.com\"},{\"id":\"364075-13\",\"http://www.xyz.com\"},{\"id\":\"364121-13\",\"http://www.efg.com\"}]";
boolean b = Pattern.matches(pttrn, mtchr);
System.out.println("b is !!" + b);
我期待 b 为真,但它返回假。我弄错了正则表达式。
请让我知道如何解决它。
谢谢