-1
你好,我是新^0 *正则表达式是不是正则表达式中使用的Java
^0* -
g
^ asserts position at start of the string
0* matches the character 0 literally (case sensitive)
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Global pattern flags
g modifier: global. All matches (don't return after first match)
弦乐“3454tdfgffg”它应该返回false,因为没有零
下面是我的榜样
public class RegExTest {
public static void main(String args[]){
String pattern ="^0*";
String instance = "3454tdfgffg";
// Create a Pattern object
Pattern r = Pattern.compile(pattern);
// Now create matcher object.
Matcher m = r.matcher(instance);
if (m.find()) {
System.out.println("Available");
}else
{
System.out.println("Not available");
}
}
}
,但它始终返回true,什么都在我的实例变量写
可以哟你请解决我,我错了我
感谢反斜线:)它; S工作 –
不知道为什么这样的人downvote,我已经返回我没有多少知识 –
@SiddhpuraAmit我认为这是因为它也写在你的问题中:'*量词 - 在零和无限次之间匹配,尽可能多次,根据需要回馈(贪婪)'。无论如何,正则表达式可能是困难的,如果你是他们新手,所以我很高兴答案:) – BackSlash