zoukankan      html  css  js  c++  java
  • 测试RegExp对象的属性

    //测试RegExp对象的属性
    function testRegExpProperty(){
    var regexp = /abc/;

    //regexp.ignoreCase = true; //无效

    console.log(regexp.ignoreCase);
    console.log(regexp.global);
    console.log(regexp.multiline);
    console.log(regexp.source); //源文本
    console.log(' '); //源文本

    //学号都必须以S、G、D开头,后跟4位数字,表报名的次序号
    //如 G1588 D0102
    var txt = 'G0102'; //假设是用户输入的一个学号
    var regexp = /^([sgd])(d{4}$/i;

    console.log( regexp.test(txt) );
    console.log( RegExp.$1 ); //保存着最近一次匹配中第一个分组的实际内容
    console.log( RegExp.$2 ); //保存着最近一次匹配中第二个分组的实际内容
    console.log( RegExp.$3 );
    console.log( RegExp.$4 );
    }

    我的github: https://github.com/moux1024
  • 相关阅读:
    表单
    html 基础代码
    thread
    流的存入读取
    异常

    Android——多线程编程练习题
    Android——进度对话框
    安卓3个练习题
    Android—对话框
  • 原文地址:https://www.cnblogs.com/xd1024/p/4637785.html
Copyright © 2011-2022 走看看