Hi I’m struggling to understand why my Regex isn’t working. I have URL’s that have DOI’s on them like so: And I’m using for example this Regex, but it always returns empty? Where have I gone wrong? Answer It looks like you come from another programming language that has the notio…
Tag: regex
Capture sequence of words separated by whitespace thru existing regex
Following up from an earlier version of this question asked here. I have a string of the form — test = “<bos> <start> some fruits: <mid> apple, oranges <mid> also pineapple <start> some animals: <mid> dogs, cats <eos>” which needs to be converted to …
How to extract exact match from list of strings in Python into separate lists
This is an example list of strings I would like to extract XIC(Switch_A) into one list, OTE(Light1) into another list, TON(Motor_timer) into another list and so on. This is the code in Python 3 that I have tried How do I go about extracting OTE(Tag name), XIC(Tag name), XIO(Tag name) into their own lists or g…
Regex returns empty string despite working on regex101 python [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 7 months ago. Improve this question I…
Python Regex for Searching pattern in text file
Tags in Sample.txt: <ServiceRQ>want everything between…</ServiceRQ> <ServiceRQ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance>want everything between</ServiceRQ> .. Please can someone help me to get the regex? To extract the expected output from a text file. I want to…
Python pandas .str.split regex=True ValueError: Columns must be same length as key
I need help with this pandas split with regex. I’m getting the error ValueError: Columns must be same length as key. my column of data is like this my code is desired results would be. Answer Given: Doing: Output: Works fine for me.
Python regex: Negative look-ahead with selection of different length strings
I’m searching for a Regex pattern in Python 3.8 that matches a sequence of strings if and only if it’s not followed by a selection of other strings. For example, I want to match the pattern “<fruit> and <fruit>” only if the second fruit isn’t followed by “ice…
What would be the regex pattern for the following?
I have multiple regex strings in format:- Example: A=’AB.224-QW-2018′ B=’AB.876-5-LS-2018′ C=’AB.26-LS-18′ D=’AB-123-6-LS-2017′ E=’IA-Mb-22L-AB.224-QW-2018-IA-Mb-22L’ F=’ZX-ss-12L-AB-123-6-LS-2017-BC-22′ G=’AB.224-2018′ H=R…
Python convert all-caps into title case without messing with camel case
I’m using python3 and would like to turn strings that contain all caps words (separately or inside a word) into title case (first letter capitalized). I do not want to disrupt one-off capital letters in the middle of a word (camel case), but if there are repeated capitalized letters, I want to keep only…
Python Regex: multiple regrex causing problem
A basic version of this problem is using an regex to translate something like abc like ‘%FFddsdE%’ into LOWER(abc) like ‘%ffddsde%’ and the following code works well However, everything crash down if we want to expand this problem a little bit, to both like and not like It gives LOWER(…