Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

re, regex helping in python to extract text from special tags

【AP】【TEST】<testing art>※collected items.《item name》[settings]

for the example above, how can i use re with regex to extract all the things inside a specific tags?

i will need the

  • AP
  • TEST
  • testing art
  • collected items.
  • item name
  • settings

i am not sure which regex should i use for the re part in python

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

One way by extracting either letters, spaces or dots:

s = "【AP】【TEST】<testing art>※collected items.《item name》[settings]"
re.findall("[\w \.]+", s)

Output:

['AP', 'TEST', 'testing art', 'collected items.', 'item name', 'settings']
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading