Home > front end >  A regular expression
A regular expression

Time:09-28

A regular expression, can find out which begin with # define content:

A piece of string, a lot of lines to find among them with "# define XXX_YYY" all lines, including X and Y are capitalized, middle underlined
But hope to be able to do it:
1. _YYY does not necessarily have a
2. # define XXX_YYY behind can not have a specific definition
3. The XXX and YYY is arbitrary length capital

For example:
'# define XYZ can
''# define xyz not
''# define XYZ_A can
''# define XYZ_a not
'Not '# define XYZ_A 0'
Not '# define PI 3.14

Feeling a bit complicated
Sincerely help thank you

CodePudding user response:

String. The match (/^ # define [a-z] + (_ [a-z] +)? $/mg)
  • Related