Skip to content

Tag: regex

Using Split method or Regex to separate string

In my project I am webscrapping UFC website to gather to the total wins, total losses, and total draws of each UFC athlete. This is part of my code, as I wish to strip the total wins, total losses, and total draws separately: The result is the following: The problem is, I am unable to spew out the total draws…

Function with two loops

I want to make a function what must have 2 loops: must check that at least 2 characters (letters) are inserted if the two characters are in the form that the variable must receive at the end, the variable receives the correct orthographic form. Here is my code (but it throws me in infinite loop) [Please be in…

regex find first occurance beginning from end of the line

I have this string How would I go on about matching from the last occurance of start to the end of the line? I tried to do this with a negative lookahead but I would always get the first occurance: (?!$)\nstart[sS]*?$ Expecting match to be characters: 164-219 Answer You can use See the regex demo. Details: (?…

How to match “cc dd” that doesn’t start with “aa”

I want to match cc dd that doesn’t start with aa Result: Current Result: I want .. Answer With re, it won’t be possible to achieve what you need because you expect multiple occurrences per string that will be replaced later, and you need a variable-width lookbehind pattern support (not available i…

Regex XML Selection Extract Element

I am trying make a regex selection starting from BYPASS 0 0 0 up to and including the section where it says WAK 0 0 Here is what I have (?s)(?=BYPASS).*?(WAK….) I think my syntax for python use is incorrect also here is how I use it in python script re.split(r'(?s)(?=BYPASS).*?(WAK….)’, r) I…

Regex to split text based on a sentence pattern

I have a text that looks something like: ‘19:54:12 From X to Y: some text after 21:08:15 From A to B:another text’ I want to split the text based on the 19:54:12 From X to Y: sentence pattern. Ideally the result would look something like this [‘19:54:12 From X to Y:’, ‘ some text after’, ‘21:08:15 From A to B…

Regex – How to account for random spacing/line breaks in a term

I am using Python and have the following regular expression to extract text from text files: My issue is specifically with the last term, “Pursuant to the requirements of the Securities Exchange Act of 1934”. In the text files, this sentence is sometimes spaced randomly and starts different parts …