-1

I can print debug output for python regex as follows:

import re 
p = re.compile(r'[\w\.-]+@[\w\.-]+', re.DEBUG)

Where it produces the following:

MAX_REPEAT 1 MAXREPEAT
  IN
    CATEGORY CATEGORY_WORD
    LITERAL 46
    LITERAL 45
LITERAL 64
MAX_REPEAT 1 MAXREPEAT
  IN
    CATEGORY CATEGORY_WORD
    LITERAL 46
    LITERAL 45

 0. INFO 4 0b0 3 MAXREPEAT (to 5)
 5: REPEAT_ONE 12 1 MAXREPEAT (to 18)
 9.   IN 7 (to 17)
11.     RANGE 0x2d 0x2e ('-'-'.')
14.     CATEGORY UNI_WORD
16.     FAILURE
17:   SUCCESS
18: LITERAL 0x40 ('@')
20. REPEAT_ONE 12 1 MAXREPEAT (to 33)
24.   IN 7 (to 32)
26.     RANGE 0x2d 0x2e ('-'-'.')
29.     CATEGORY UNI_WORD
31.     FAILURE
32:   SUCCESS
33: SUCCESS

So, how I can read this?

Khamidulla
  • 2,797
  • 5
  • 28
  • 56
  • Read it as a text string and use it somewhere in your program? – prieber May 17 '21 at 02:44
  • @prieber I want to understand how this debug will help me understand why my regex is not working. – Khamidulla May 17 '21 at 09:21
  • You are reading the wrong text. Read [the regex explanation here](https://regex101.com/r/6iE4N8/1). – Wiktor Stribiżew May 17 '21 at 22:15
  • @WiktorStribiżew I knew how to read regex expression. But I want to understand debug output, read it, and know-how to apply it to its debug. There is no sufficient information in python documentation. PS: Link you shared is for outdated python 2.7. I suggest using https://www.debuggex.com/ which also shows regex in visual way. – Khamidulla May 18 '21 at 22:40

0 Answers0