Skip to content
Advertisement

Tag: regex

Regex Match on String (DOI)

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 notion of regex literals that are delimited with forward slashes

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 a dictionary (<str>:[List]) of the form: {“some fruits:” : [“apples, oranges”, “also pineapple”], “some animals:” [“dogs,

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’m trying to do a regex on this string And it must return

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 create a regex to find the above tags. This is what is have tried re.search(r”<(.*?)RQ(.*?)>(.*?)</(.*?)RQ>”, line) but not working properly. I want to make a search based on

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=”AB.224/QW/2018′ I=”AB/224/2018′ J=’AB-10-HDB-231-NCLT-1-2017 AD-42-HH-2019′ K=”AB-1-HDB-NCLT-1-2016 AD-42-HH-2020′ L=’AB-1-HDB-NCLT-1-2016/(AD-42-HH-2020) I want a regex pattern to get the output for the numbers that occur after the alphabets(that appear at the start) as well as the first alphabets. And at last years that are mentioned at last. There are

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 the first one capitalized. Here’s the

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(not) in the output. I am using python 3 btw. Thanks

Advertisement