zoukankan      html  css  js  c++  java
  • 条件正则过滤筛选 V2

    迭代提炼抽象自条件正则过滤筛选 V1

    概要:

    • 基础语法实现的PRCE单语句正则查找,捕获可选模式的左右部分。

    功能:

    • 依据模式S,条件性(不)执行——查找(可选的)首个目标模式T,捕获其左侧$1、右侧$2文本。

    实现:

    • 使用PCRE正则的基础语法(未使用实验性、高版本功能,兼容性高):
      • Lazy Quantifier惰性求值;
      • Positive Lookahead前向匹配断言;
      • (?:T|$) 推进对可选目标模式的全文检测,避免回溯(Backtracking)。

    参考:

     1 (?#skip match process when S exist, or remove optional left most target T, capture left and right part of T.
     2 Use case: if N is not exist, modify/change T to N, or create N. If any create or modify write operated, appending output N to right.
     3 skip exist:)^(?!.*S)(?#
     4 captrue prefix :)^(.*?)(?#
     5 optional target to remove:)(?:T|$)(?#
     6 captrue postfix:)(.*?)$(?#
     7 Test string:
     8 aa
     9 aaT
    10 Tcc
    11 aaTcc
    12 aaTbbTcc
    13 aaS
    14 aaTS
    15 TccS
    16 aaTccS
    17 Saa
    18 SaaT
    19 STcc
    20 SaaTcc
    21 Substitution: $1$2N
    22 Return:
    23 aaN
    24 aaN
    25 ccN
    26 aaccN
    27 aabbTccN
    28 aaS
    29 aaTS
    30 TccS
    31 aaTccS
    32 Saa
    33 SaaT
    34 STcc
    35 SaaTcc)
    View Code

     维护最新版本见create or change one optional part to another (58bd3z/1)

  • 相关阅读:
    HQL语句中类的别名语法以及作用?
    C#面向对象
    c#异步编程一
    c#接口
    c#Socket通信基本使用
    c#FTP基本使用
    c#XML的基本使用
    c#装箱与拆箱
    c#数组与集合
    c#中for与foreach的使用
  • 原文地址:https://www.cnblogs.com/RobertL/p/14136714.html
Copyright © 2011-2022 走看看