Introduction to Regular Expression

Introduction to Regular Expression

@(NLP)

[TOC]

導(dǎo)論

Q1 什么是Regular Expression?
Q2 Regular Expression 有什么用?
Q3 Regular Expression 怎么寫?
Q4 R中哪有寫實(shí)用的Regular Expression的包或者函數(shù)?

Definition

wiki: A regular expression, regex or regexp(sometimes called a rational expression) is, in theoretical computer science and formal language theory, a sequence of characters that define a search pattern. Usually this pattern is then used by string searching algorithms for "find" or "find and replace" operations on strings.

涉及的領(lǐng)域:theoretical computer science; formal language theory
內(nèi)涵:a sequence of characters that define a search pattern
通常運(yùn)用:used by string searching algorithms for "find" or "find and replace" operations on strings.

Basic concepts

A regular expression, often called a pattern, is an expression used to specify a set of strings required for a particular purpose.

features:

  1. a simple way to specify
  2. more concise ways to specify
  3. the specification is not unique

operations to construct regular expressions:

  1. Boolean(布爾數(shù)學(xué)體系的) "or"
    A vertical bar(豎線) separates alternatives. For example, gray|grey can match "gray" or "grey".

Boolean是否只能是兩者選?
alternatives表示可選擇的、備用的;沒(méi)有二選一的意思。

  1. Grouping
    Parentheses(圓括號(hào)) are used to define the scope(范圍) and precedence(位次) of the operators (among other uses).For example, gray|grey and gr(a|e)y are equivalent patterns which both describe the set of "gray" or "grey".

參考

百度百科
wiki
入門1
中文正則測(cè)試網(wǎng)站

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容