Category : re

I’m extremely new to Python, so I’m sorry if my question is rather stupid. I have a bunch of long strings in one list and shortened parts of it in another list Like: Long string is D:PythonSongstestsong.mp3 and short string is testsong.mp3 And I want to get a list containing ‘Songs’ (basically the name of ..

Read more

I am trying to resolve one task. I have some sentences in other file, which I have to fix. For example: M[a/e|10]n with ap[l/p|01]le. Result should be: Man with apple. If word ends with 10, it should write the first letter(A). If word ends with 01, it should write the second letter (E). I was ..

Read more

I’m somewhat stuck with this and didn’t find a similar issue here. I want to get a list of all the tag elements in the string like, e.g. < a> -> a or < /b > -> b import re s = ‘<p><a href="http://www.quackit.com/html/tutorial/html_links.cfm">Example Link</a></p>’ pat = r'<s*(w+)/?s*.*>’ tags = re.findall(pat, s) print(tags) Here I ..

Read more

I have a response from an API that is a pseudo dictionary with some ‘key’:’values’ but mostly just a blob of text with ‘key:values’. I convert it with .json() to this {‘status’: ‘done’, ‘nextLogId’: ‘AQAAAXb’, ‘logs’: [{‘content’: {‘service’: ‘t2pipeline’, ‘tags’: [‘tag1:value1’, ‘tag2:value2’, ‘tag3:value3’], ‘timestamp’: ‘2021-01-05T05:25:03.416Z’, ‘host’: ‘i-00e17’, ‘attributes’: {‘caller’: ‘psignal/state_machine.go:451’, ‘ts’: 1609824303.416246, ‘level’: ‘warn’}, ‘message’: ..

Read more