Representing identifiers using Regular Expression

后端 未结 2 1140
鱼传尺愫
鱼传尺愫 2021-02-18 17:33

The regular definition for recognizing identifiers in C programming language is given by

letter -> a|b|...z|A|B|...|Z|_
digit -> 0|1|...|9
identifier -&g         


        
2条回答
  •  终归单人心
    2021-02-18 18:13

    The regular expression you are looking for is:

    [_a-zA-Z][_a-zA-Z0-9]{0,30}
    

    It will match an underscore or letter following by X underscores, letters or numbers, where 0 <= X <= 30

提交回复
热议问题