Regular expression

xiaoxiao2021-03-06  59

Regular expression

1. {1,} {1,} matches all {2,} "matches all BBBs in" abbb "but does not match any characters in" AB "

Example: var str0 = "aaabcbbb" str0 = str0.replace (/ b / g, "k"); document.write (str0); document.write ("
")

Var str = "aaabcbbb" str = str.replace (/ b {1,} / g, "k"); Document.write (STR); document.write ("
")

Var str1 = "aaabcbbb" str1 = str1.replace (/ b {2,} / g, "k"); Document.write (STR1);

Output: Aaakckaaabckaaakckkkk

2. $ this should be all matches, not a character in the string (the verification)

Must be a digital var r = /^[0-9】}; document.write ("/" ");

3. [0-9%.] 0-9 Don't say,%. It is the accumulation of match characters.

转载请注明原文地址:https://www.9cbs.com/read-111727.html

New Post(0)