regex for C-like identifier
match an C-like identifier
^[a-zA-Z_][0-9a-zA-Z_]*$
Regex Flags
global match
?
ignore case
?
multiline
?
dotAll
?
unicode
?
sticky
?
abc123
PascalCase
camelCase
snake_case
_test
_
123abc
In computer languages, identifiers are tokens (also called symbols) which name language entities
The identifiers are the names given to variables, structures, functions etc in programming languages like C.
An identifier can have alphabets, numbers, and underscore (_).
Identifiers cannot start with numbers.
Note: Keywords cannot be used as an identifier
Cheatsheet
expr | usage |
---|---|
/[a-zA-Z]/ | matches all lowercase and uppercase letters |
/ab*c/ | matches zero or more repetitions of "b" (matches "abc", "abbbbc", "ac") |
/^/ | matches beginning of a line |
/$/ | matches end of a line |
iHateRegex
by
geon