无为清净楼资源网 Design By www.qnjia.com

从正则表达式生成随机数据

项目地址

https://github.com/GitHub-Laziji/reverse-regexp

安装

git clone https://github.com/GitHub-Laziji/reverse-regexp.git
cd reverse-regexp
mvn install
<dependency>
  <groupId>org.laziji.commons</groupId>
  <artifactId>reverse-regexp</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

使用

随机字符语法

支持大部分正则表达式的匹配语法

  • \d 数字, 相当于[0-9]
  • \w 数字、字母加下划线, 相当于[0-9a-zA-Z_]
  • \s 空白字符, 只包含空格和制表符
  • . 除\n和\r以外的任意字符, 生成随机字符时只在ascii码0~255之间生成
  • [a-zA-Z甲乙] 区间, 不支持^语法
  • 以及其他字符

重复打印语法

与正则表达式的重复匹配语法相同

  • "htmlcode">
    public class MainTest {
    
      @Test
      public void test() throws RegexpIllegalException, UninitializedException, TypeNotMatchException {
        
        random("\\w{6,12}@[a-z0-9]{3}\\.(com|cn)", "邮箱");
        random("1(3|5|7|8)\\d{9}", "手机号");
        random("-", "浮点数");
        random("https", "网址");
      }
      
      private void random(String expression, String title)
          throws RegexpIllegalException, TypeNotMatchException, UninitializedException {
        
        System.out.println(title + " " + expression);
        Node node = new OrdinaryNode(expression);
        Pattern pattern = Pattern.compile(node.getExpression());
        for (int i = 0; i < 10; i++) {
          String data = node.random();
          System.out.println("[" + pattern.matcher(data).matches() + "] " + data);
        }
        System.out.println();
      }
    
    }
    
    

    输出
    邮箱 \w{6,12}@[a-z0-9]{3}\.(com|cn)
    [true] 19cZ8eISNA@9je.com
    [true] xpv3wJ@i3h.cn
    [true] 6qDUfY@1g9.com
    [true] iVnZSMA373@6zd.cn
    [true] I5wiX97@ffe.cn
    [true] mwqA5sXQ@g8j.cn
    [true] HUXiCem1Y0w@j98.cn
    [true] 1jOQWsELF@u1o.cn
    [true] _Q4QTvxPeMFh@bds.com
    [true] 3xFH33Aa@6lh.cn

    手机号 1(3|5|7|8)\d{9}
    [true] 18263364656
    [true] 17539493178
    [true] 17452542895
    [true] 15190699623
    [true] 13441385631
    [true] 15450856416
    [true] 18651247283
    [true] 13835809899
    [true] 18595798569
    [true] 17115703866

    浮点数 -"https://a_fl.thx/4_4" rel="external nofollow" >https://a_fl.thx/4_4
    [true] http://v3YTuJ0Gu-5z8.JGhpdLe/V2j/ndL-UO
    [true] https://FuMG-gafEc.R2FRRtLyX/ahg
    [true] https://5phYVK9.wh7vl9z3AAZVg.z-yQSiMTdQw8S9-/WKCd
    [true] https://T9dntbI.4Su8vxYhCr6"http://qhydgqbtywq6stg8.i6gb-m_ripkieafk/" rel="external nofollow" >http://qHyDgqBtYwq6Stg8.I6gb-M_ripkiEafK"http://uj.yb3foktjky-uqkul.zxrrfuk9k/Dcymu" rel="external nofollow" >http://UJ.Yb3foKTJKy-uqKUl.ZXrrFUk9K/Dcymu"https://by_is.tnlclavxmkuo.t90g5xetj/cQncGI" rel="external nofollow" >https://BY_iS.tnlclAvxMkuO.T90G5XETj/cQncGI
    [true] http://hG.li8Nzv.uaGokB/CTnrqp
    [true] https://huZmN.v-LtoY/Dyl/peq?NUmt=__QDXG&8GBY=wZ8M&AkKZl4=8NZfEt

    以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

标签:
正则表达式生成随机数,正则表达式,随机数

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。