zoukankan      html  css  js  c++  java
  • Java regex Lookaround

    1. see: http://www.rexegg.com/regex-lookarounds.html
    2. Four ways of using lookarounds:
      • (?= lookahead
        • (?=d{3} dollars).{3} (Lookahead). Looks ahead for three digits followed by " dollars". Matches "100" in "100 dollars"
      • (?! negative lookahead
        • (?!=d{3} pesos)d{3} (Negative Lookahead). Makes sure what follows is not three digits followed by " pesos". Matches "100" in "100 dollars"
      • (?<= lookbehind
        • (?<=USD)d{3} (Lookbehind). Makes sure "USD" precedes the text to be matched. Matches "100" in "USD100"
      • (?<! negative lookbehind
        • (?<!USD)d{3} (Negative Lookbehind). Makes sure "USD" does not precede the text to be matched. Matches "100" in "JPY100"
    3. Lookaround after match:
      • d{3}(?= dollars) (Lookahead). Makes sure " dollars" follows the three digits to be matched. Matches "100" in "100 dollars"
      • d{3}(?! dollars) (Negative Lookahead) Makes sure " dollars" does not follow the three digits to be matched. Matches "100" in "100 pesos"
      • .{3}(?<=USDd{3}) (Lookbehind). Looks behind for "USD" followed by three digits. Matches "100" in "USD100"
      •  d{3}(?<!USDd{3}) (Negative Lookbehind). Makes sure what precedes is not "USD" followed by three digits. Matches "100" in "JPY100"
    4. n
    5. n
    6. n
    7. n
  • 相关阅读:
    通用测试用例(二)
    loadrunner基础学习笔记八-分析场景
    loadrunner基础学习笔记七-面向目标场景
    Detect the Virus ZOJ
    考研路茫茫——单词情结 HDU
    DNA Sequence POJ
    病毒侵袭持续中 HDU
    病毒侵袭 HDU
    Keywords Search HDU
    codeforces 949B :A Leapfrog in the Array 找规律
  • 原文地址:https://www.cnblogs.com/wade-case/p/3381739.html
Copyright © 2011-2022 走看看