[英]Regular expression in a regular expression?
我只需要知道是否有可能在正則表達式的定義內包含一個正則表達式。
這是我要嘗試做的事情:我已經為整數,自然數,正整數和負整數定義了正則表達式。 現在,我想使用這些已經存在的正則表達式來定義分數的正則表達式。
Consider
token_int is the regex for integers
token_natural is the regex for natural numbers
token_neg_int is the regex for negative integers
I would like the fraction regex to be defined as:
token_frac = token_int'/'(token_natural | token_neg_int)
如果我對您的理解正確,那么可以。 但是以以下方式(由於正則表達式是字符串):
token_frac = token_int + '/(' + token_natural + '|' + token_neg_int + ')'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.