I am trying to write a regular expression that captures octal characters.
For example, if the line that I am comparing with my regular expression looks like this:
char x = '\077';
I want my regular expression to capture '\077'
I tried to do this through a re-module and a regular expression of the form:
"'\\[0-7]{1-3}'"
But this does not reflect the octal character. How can octal characters be identified using regex in Python?
Edit:
As an example of what I mean, consider the C code:
char x = '\077';
printf("%c", x);
I would like to write '\077'from the first line.
Edit:
, , . , r , .
, :
regex = re.compile(r"\s*("
r"'\\0[0-7]{1,2}'"
"|[a-zA-Z_][a-zA-Z_\d]*"
")")
regex.findall(line)
regex = re.compile(r"\s*("
"'\\\\0[0-7]{1,2}'"
"|[a-zA-Z_][a-zA-Z_\d]*"
")")
regex.findall(line)
'\077', : char = '\077';
.