python - Parse items from text file -


I have a text file that contains data inside {{}} tags. It will be recommended to parse data, So can I just use the data inside the tag?

The example text file will look like this:

'This is a bunch of text that {{really}} is not useful in any [[pathways]}. I need some things from {[to]}. '

I would like to end in a list with' really ',' path ',' get ',' to '. I think I can use split to do this .. but it seems that there can be a better way. I have seen a ton parsing library, is there anybody I want to do?

I use regular expressions, the answer assumes that none of the tag characters {} The tag does not appear within the characters.

  import re text = 'This is a bunch of text that is not useful in [[really]} any [[route]} from me [from]} some things ]} is required. For 're Python's regular expression using Python mode:  

Pre-> re.findall ('' '# # # curly breech opening [#] after an open square bracket (# Capturing the next pattern. * # # After anything at least possible sequence) # Capture End] # Close the intersection after bracket. # # A close curly brace '' ', text, after re-overboss)


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -