10PL
2 つの正規表現が必要です。これは、 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));
結果はすべて null でした (document.write は何も書き込みませんでした)。では、これら2つのパターンの正規表現を理解するのを手伝ってくれる人はいますか?