Category : regex

I have following code, which extracts text between the BusContact tag. But I want to print the text in two lines. In summary, replace ‘|’ symbol with ‘n’. I have used re module. searchstring = ‘<BusContact>kdsfdfskfsdffsdsdf|sdfsdfsdfsdfsdf</BusContact>’ import re contactdetail = re.compile(‘<BusContact>(.*?)</BusContact>’).search(searchstring) buscontactdetail = contactdetail.group(1) print(buscontactdetail) Current output: kdsfdfskfsdffsdsdf|sdfsdfsdfsdfsdf Expected Output: kdsfdfskfsdffsdsdf sdfsdfsdfsdfsdf Source: Python..

Read more

I have this program from datetime import datetime class stoc(): def __init__(self, nameprod, categ, um=’Buc’, sold=0): self.nameprod = nameprod self.categ = categ self.um = um self.sold = sold self.dd = {} self.di = {} self.de = {} def enter(self, cant, data=str(datetime.now().strftime(‘%Y%m%d’))): self.cant = cant self.data = data if self.dd.keys(): cheie = max(self.dd.keys()) + 1 else: ..

Read more

How to enforce python regex search/find functions to move on to the next character instead of skipping the entire matched group? For example import re s = "a123b4567" re.findall(r"d{2}", s) # match two digits This gives the following as one would normally expect. Note that ’12’ is skipped, so ’23’ won’t match. [’12’, ’45’, ’67’] ..

Read more

I have a dataframe like as shown below tdf = pd.DataFrame({‘text_1’:[‘value: 1.25MG – OM – PO/TUBE’, ‘value:2.5 MG – OM – PO/TUBE’,’value: 18 UNITS(S)’,’value: 850 MG – TDS AFTER FOOD – SC (SUBCUTANEOUS)’, ‘value: 75 MG – OM – PO/TUBE’]}) I would like to apply regex and create two columns based on rules given below ..

Read more

I am trying to convert a String into proper JSON notation. This string, got some correct indexes (with [idx]), and some incorrect indexes (with dot notation .idx. with these last ones starting by 1, instead of by 0). Is there anyway to "handle" captured groups using python re library or similar? This is what I ..

Read more

I am getting below error only when i am trying to access the website via domain name. When i access my website using ip address (by running python manage.py runserver) it doesn’t throw an exception. Please check using below: https://adhocdevices.com/ Please help me in resolving this issue. My urls.py is as below: path(‘category/<int:pk>/’,views.CategoryShow), path(‘about/’,views.about,name=’about’), path(‘contact/’,views.contact,name=’contact’), ..

Read more