regex - Separate text from hyphens line -


i wondering if there better approach taking parse file. have string in general format of:

[chunk of text] -------------------- [another chunk of text] 

(there can multiple chunks of text same separator between them)

i trying parse chunks of text elements of list, can data.split('-'*20) [in case], if there not 20 hyphens split not work intended. have been playing around regex unsure of proper regex used.

are there better methods should use in situation, or there regex should use oppose .split() method?

you want regex split. i'm not python-literate, found function in official 2.7.10 documentation, , modified case:

>>> re.split('\n\-{4,}\n', input) 
  • 4 minimum amount of dashes want match.
  • \n newlines before , after. don't want in text.

Comments