Python regex find text in bullets& numbering list -
i'm trying find text in bullet& numbering using regex in python
for example
indesign docs provides series of articles using bullets , numbering create outlines, multi-level lists, figure captions, , numbered steps.
- blah blah blah blah
- blah2 blah2 blah2
- blah3 blah3 blah3
i want grab text after numbering & bullet list
for example
blah blah blah blah
blah2 blah2 blah2
blah3 blah3 blah3
this code tried:
import re n= re.compile('\d\.\s+(.*)') test2= """ test name aaaaaa 1. blah blah blah 2. blah2 blah2 blah2 3. blah3 blah3 blah3 4. blah4 blah4 blah4""" print n.search(test2).group(0)
dot doesn't match newline, unless specify re.dotall
; then, need constrain match not match text through end of document.
also, need double backslashes in regex string, or use r'...'
string syntax.
maybe r'(\d+\.\s.*\n?)+'
work needs?
Comments
Post a Comment