mardi 16 mars 2021

How can I find some patterns in text lines?

For example i had some text lines like this:

[MAN_14] Name=Alex Age=3 Number=2

[ROBOT_1] Name=Alex Age=3 Number=2

etc...So I want to find and print all lines that starts with [MAN_?] and i.e only Name:

[MAN_14] Name=Alex [MAN_15] Name=Nick etc

How can I do it? I try if line.startswith() but I find only '[M' or only 'Name=', not both I think regex and regular expressions needs here Plz help!

Aucun commentaire:

Enregistrer un commentaire