emory-courses / computational-linguistics

Computational Linguistics.
90 stars 100 forks source link

match object .start(g) method #6

Closed caroltang0331 closed 2 years ago

caroltang0331 commented 3 years ago

In the python docs example m = re.search('b(c?)', 'cba'), what does the 1 in n.start(1) means? and why is it 2? Thankyou

@jdchoi77

jdchoi77 commented 3 years ago

@caroltang0331 could you give me the context of this code? It's hard for me to tell what n is. In general, the start(1) would give the starting offset of the first group matched.

caroltang0331 commented 3 years ago

I'm sorry I think I meant m instead of n. I have attached the context. The document said it creates a substring matched by group but I'm a bit confused on what it means. Thank you

Screen Shot 2021-02-12 at 9 52 11 AM