/** var expression =/Pattern/flags * Regular expression can have one or more flags to flag the expression's behavior * Regular expressions Support 3 flags: * g: Indicates full mode, that is, the pattern will be applied to all strings instead of stopping immediately when the first match is found. * I: Indicates ignoring case * M: indicates that any metacharacters used in multiple lines * * mode must be escaped. * */ /*================================= The following are regular expression literal forms =============================*/ varPATTERN1 =/at/g;//match all ' at ' varpattern2 =/[bc]at/i;//match the first ' bat ' or ' cat ', ignoring case varPattern3 =/\[bc\]at/i;//Match [Bc]at varPattern4 =/.at/gi;//matches all combinations of characters ending with ' at ', not case-sensitive. varPattern5 =/\.at/gi;//matches all. At, not case sensitive. /*================================ The following is the form of the RegExp constructor ===============================*/ /** * The RegExp constructor has 2 parameters: the string pattern to match, and the other optional flag string * Expressions that can be defined in literal form can be defined by constructors. * */ varREG1 =NewRegExp ("[Bc]at", "I"); varReg =NULL; vari = 0; for(; i < ten; i++) {reg=/cat/G; Console.log (Reg.test ("Catastrophe")); } varRe =NULL; for(i = 0; i < i++;){ }
Blog Style test