写了则正则表达式,java可以通过,但是js 不能通过,求指导
^(?<!,)+((?<!-)+((([0-1]\\d|2[0-3]):[0-5]\\d)-?){2,}+(?<!-),?){1,}+(?<!,)$String[]str...
^(?<!,)+((?<!-)+((([0-1]\\d|2[0-3]):[0-5]\\d)-?){2,}+(?<!-),?){1,}+(?<!,)$
String[] str = {"09:30-","09:30-12:00","09:30-11:30,12:30-22:00","09:30-12:00,,09:30-12:00"
,"09:30-12:00,09:30-12:00,","09:30-12:00,,09:30-12:00,","09:30-12:00,09:30-12:00,,"};
for (String string : str) {
System.out.println(string + " = " +string.replaceAll(
"^(?<!,)+((?<!-)+((([0-1]\\d|2[0-3]):[0-5]\\d)-?){2,}+(?<!-),?){1,}+(?<!,)$", ""));
}
js不能通过
/^(?<!,)+((?<!-)+((([0-1]\d|2[0-3]):[0-5]\d)-?){2,}+(?<!-),?){1,}+(?<!,)$/.test(value)
实在不行求帮写个类似的正则表达式,让上面的java String[] 中 第二个或者第三个通过 展开
String[] str = {"09:30-","09:30-12:00","09:30-11:30,12:30-22:00","09:30-12:00,,09:30-12:00"
,"09:30-12:00,09:30-12:00,","09:30-12:00,,09:30-12:00,","09:30-12:00,09:30-12:00,,"};
for (String string : str) {
System.out.println(string + " = " +string.replaceAll(
"^(?<!,)+((?<!-)+((([0-1]\\d|2[0-3]):[0-5]\\d)-?){2,}+(?<!-),?){1,}+(?<!,)$", ""));
}
js不能通过
/^(?<!,)+((?<!-)+((([0-1]\d|2[0-3]):[0-5]\d)-?){2,}+(?<!-),?){1,}+(?<!,)$/.test(value)
实在不行求帮写个类似的正则表达式,让上面的java String[] 中 第二个或者第三个通过 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询