python-re

search for two identical characters and filter them on python

search for two identical characters and filter them on python Question: how this task can be carried out is more optimized. Various data come to me. Example data : test/123, test , test/, test/123/ and I need to write the correct data to my database, but first I need to find it. The correct ones …

Total answers: 1

Perform multiple regex operations on each line of text file and store extracted data in respective column

Perform multiple regex operations on each line of text file and store extracted data in respective column Question: Data in test.txt <ServiceRQ xmlns_xsi="http://"><SaleInfo><CityCode>DXB</CityCode><CountryCode>EG</CountryCode><Currency>USD</Currency><Channel>TA</Channel></SaleInfo><Pricing><CustomParams><Param Name="AG"><Value>95HAJSTI</Value></Param></CustomParams></Pricing></ServiceRQ> <SearchRQ xmlns_xsi="http://"><SaleInfo><CityCode>CPT</CityCode><CountryCode>US</CountryCode><Currency>USD</Currency><Channel>AY</Channel></SaleInfo><Pricing><CustomParams><Param Name="AG"><Value>56ASJSTS</Value></Param></CustomParams></Pricing></SearchRQ> <ServiceRQ xmlns_xsi="http://"><SaleInfo><CityCode>BOM</CityCode><CountryCode>AU</CountryCode><Currency>USD</Currency><Channel>QA</Channel></SaleInfo><Pricing><CustomParams><Param Name="AG"><Value>85ATAKSQ</Value></Param></CustomParams></Pricing></ServiceRQ> <ServiceRQ …… <SearchRQ …….. My code: import pandas as pd import re columns = [‘Request Type’,’Channel’,’AG’] # data = pd.DataFrame exp = re.compile(r'<(.*)s+xmlns’ r'<Channel>(.*)</Channel>’ r'<Param …

Total answers: 1

Merge to lists in reverse chronological order using regular expression python

Merge to lists in reverse chronological order using regular expression python Question: I am trying to merge two lists in Python in reverse chronological order using regular expression. I’m a little lost, the only thing I can do to merge them without errors so far is concatenate them together using the ‘+’ method. These are …

Total answers: 1

python module ZipFile get base folder using regex

python module ZipFile get base folder using regex Question: Assume this zip file "acme_example.zip" contains below content of the files/folders : acme/one.txt acme/one1.txt acme/one2.txt acme/one3.txt acme/one4.txt __MACOSX .DS_Store And i am using this below script output_var = [] skip_st = ‘__MACOSX’ with ZipFile(‘acme_example.zip’,’r’) as ZipObj: listfFiles = ZipObj.namelist() for elm in listfFiles: p = Path(elm).parts[0] …

Total answers: 1

How to remove a specific part of a link?

How to remove a specific part of a link? Question: So basically Im making a script that’s able to download a bunch of maps from TrackmaniaExchange with a search result. However, to download the map files, I need the actual download link, which the search result doesn’t give. I already know how to download maps. …

Total answers: 1

python if list_item == re.match

python if list_item == re.match Question: I’m trying to practice regex patterns with conditions in python (googlecollab), but stuck in (if… and…) by getting proper numbers from the list[000 to 999] – i need only numbers, ending with one digit ‘1’ (not 11, 111, 211 – I need only 001, 021, 031, 101), but it …

Total answers: 1

match multiple substrings using findall from re library

match multiple substrings using findall from re library Question: I have a large array that contains strings with the following format in Python some_array = [‘MATH_SOME_TEXT_AND_NUMBER MORE_TEXT SOME_VALUE’, ‘SCIENCE_SOME_TEXT_AND_NUMBER MORE_TEXT SOME_VALUE’, ‘ART_SOME_TEXT_AND_NUMBER MORE_TEXT SOME_VALUE] I just need to extract the substrings that start with MATH, SCIENCE and ART. So what I’m currently using my_str = …

Total answers: 2

Which regular expression do I have to implement to extract text between two lines containing a string and an arbitrary number of digits?

Which regular expression do I have to implement to extract text between two lines containing a string and an arbitrary number of digits? Question: That’s the code I have: text = ‘LIBRO 1ndsfsdfnasdasnfgfghfnLIBRO 21nhghjnghjhjknghjhknLIBRO 333′ result = re.findall(r'(?<=LIBRO d+n)(.*?)(?=nLIBRO)’, text, re.DOTALL) print(result) and this is the error I get: re.error: look-behind requires fixed-width pattern the …

Total answers: 1

Python regex does not find the pattern to parse markdown python code while regex101 does

Python regex does not find the pattern to parse markdown python code while regex101 does Question: In a markdown file, I would like to extract python code in “`python … “`(end) Using regex and python. While the python code import re text = ‘We want to examine the python codenn“`pythonndef halloworld():ntfor item in range(10):nttprint("Hello")n“` and …

Total answers: 2

How to write a regular expression correctly in python

How to write a regular expression correctly in python Question: i have the following piece of text where i need to find the threat id from the log C:\Users\Administrator\Downloads\CallbackHell.exe}rnThreatID : 2147725414rnThreatStatusErrorCode : 0rnThreatStatusID : 3rnPSComputerName : rnrnActionSuccess : TruernAdditionalActionsBitMask : 0rnAMProductVersion : 4.18.2211.5rnCleaningActionID : 2rnCurrentThreatExecutionStatusID : 1rnDetectionID : {F9B830AE-D82E-4248-9D9D-723F2FB3AF95}rnDetectionSourceTypeID : 3rnDomainUser : WIN-LIVFRVQFMKO\AdministratorrnInitialDetectionTime : 1/9/2023 …

Total answers: 1