我只需要知道是否可以在正则表达式的定义中包含一个正则表达式。
这是我想要做的:我已经为整数、自然数、正整数和负整数定义了正则表达式。现在我想使用这些已经存在的正则表达式来定义分数的正则表达式。
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)发布于 2014-11-11 14:51:49
如果我没理解错的话,那就是是的。而是以以下方式(因为正则表达式是字符串):
token_frac = token_int + '/(' + token_natural + '|' + token_neg_int + ')'https://stackoverflow.com/questions/16787248
复制相似问题