我需要两个正则表达式,它匹配任何以10PL
is结尾的东西(a single whitespace) (any integer) (the string PL in caps) (line terminates)
。我尝试了以下方法,但它们都不起作用。例如。
var str="Visit W3Schools 45PL"; // should match this
var str1="Visit W3Schools 45PL Other"; // should NOT match this
var str2 = "Any Random value 133PL" // should match this
var str3 = "Any Random value 133Pl" // should NOT match this
另一个应该匹配21.323X230
(a single whitespace) (any floating value) (the word X in caps) (any other floating point value) (line terminates)
。例如。
var test="Visit W3Schools 4X5"; // should match this
var test1="Visit W3Schools 4X5PL Other"; // should NOT match this
var test2 = "Any Random value 13.270X46.96" // should match this
var test3 = "Any Random value 13.21X12.36 " // should NOT match this, as last word is white space
我尝试了以下模式(对于第一个模式(PL 模式))。
var patt1=/\s+\d+/PL/g;
var patt2 = /[ ]+[0-9]+/PL/g;
document.write(patt1.test(str));
document.write(patt2.test(str));
document.write(patt1.test(str1));
document.write(patt2.test(str1));
document.write(patt1.test(str2));
document.write(patt2.test(str2));
document.write(patt1.test(str3));
document.write(patt2.test(str3));
结果全部为空(document.write 没有写任何东西)。那么,谁能帮我找出这两种模式的正则表达式?