Find a string between two substrings, BUT the end of the first is the start of the next one

So I have a string that goes like this: …<p><noop><fademusic:23,0><26:1><wait:30> <speed:10><30:2><5D:1><color:3>August 3, 9:47 AM<b>District Court<b>Defendant Lobby No. 2<color:0><p><hidetextbox:1><5D:0> <speed:255><music:8,0><wait:30><26:0><bgcolor:513,1,31><wait:7> <person:0,0,0><bg:2><bgcolor:258,1,31><wait:15><wait:30><hidetextbox:0> <name:512><shake:30,0><color:2>(Boy am I nervous!)<color:0><p> <hidetextbox:1><wait:45><name:1792><hidetextbox:0><bgcolor:769,8,31> Wright!<p>… What do I need: find everything between <p>s. (Note that the ending one is also a starting one for the next.) My code: … filetext = open(fn).read() tag =… Read More Find a string between two substrings, BUT the end of the first is the start of the next one

how do i extract the multiple pattern in a column value and put it in new dataframe

I am unexperienced in coding, need help in this simple code. I can’t split Index, expirydate, strike and opt type. I am stuck in splitting expiry date. **Sample 1** data = ["NIFTY2431322000PE", "NIFTY2441522000PE"] df = pd.DataFrame({‘details’: data}) # Regular expression pattern to match the desired format pattern = r'([A-Z]+)(\d{2})(\d{1})(\d{2})(\d{5})([A-Z]+)’ df[[‘Instrument’, ‘Year’, ‘month’, ‘Date’, ‘strike’, ‘CEorPE’]]… Read More how do i extract the multiple pattern in a column value and put it in new dataframe

Not more than one special symbol in a range from a long text

Simplify the problem: There is an article (long text) Extract the content between start (included) and end (included) Requirement: There cannot be more than one \n between start and end Find all matches Use python re only For code: lines = re.findall(pattern, text, re.DOTALL) for line in lines: print(line) print(‘===’) So, how can I fixed… Read More Not more than one special symbol in a range from a long text

How to format floating-point numbers in a dictionary to remove trailing and leading zeros in Python?

I have a dictionary in Python with floating-point values like this: {‘0’: 0.773, ‘1’: -0.529, ‘2’: -0.004, ‘3’: -0.035} I want to format the values in the dictionary to remove unnecessary trailing zeros and leading zeros before the decimal point. For example, I want the output to be: {‘0′:.773,’1′:-.529,’2′:-.004,’3’:-.035} How can i do it with… Read More How to format floating-point numbers in a dictionary to remove trailing and leading zeros in Python?

Python: .group "AttributeError: 'NoneType' object has no attribute 'group'"

When i put the .group() inside the "FOR" loops I get an error. import re with open(r’C:\Users\testuser\OneDrive – personal\Network\network.log’, ‘r+’) as LOG: OUTPUT = LOG.readlines() for LINE in OUTPUT: x = re.search(r’\s+name ".*"’, LINE).group() print(x) x = re.search(r’\s+name ".*"’, LINE).group() AttributeError: ‘NoneType’ object has no attribute ‘group’ Process finished with exit code 1 However if… Read More Python: .group "AttributeError: 'NoneType' object has no attribute 'group'"