Relative Content

Tag Archive for pythonregexpython-re

Extract only words using regex

I want to extract only words. The word should not contain any number or any special character attached to it, e.g. (64-bit), WebView2, x86_64. Current regex is able to ignore WebView2 and x86_64 but in the case of (64-bit) it’s returning me bit, which I don’t want. I want to exclude it because it contains numbers with -,(,) characters.

Regex not working as expected on a string

I have a string file in python that contains a number of segments “SCHOOL n:” that I would like to split the string on, where n can be any number 1-9. I am using this code snippet:

How to retrieve last dollar amount from a line

I am trying to get a code in Python that can look through a string like this one "986.80 CCF X $5.89 $5812.25" and return only the floating point number after the second “$” character. In this case it should return 5812.25

Get Regex to return just the wildcards in a string

I have tried the below example that I found on here (Python extract pattern matches) and it works perfectly. However, my actual code also below returns the wildcard part of the string plus the rest of the string that occurs after the wildcard. I don’t see what I am doing differently.

Regular Expression cannot find the match although it exists

I am trying to write a function that finds the name and positions of a gene that is in a small text. I am using the name of the gene and its possible synonyms. When testing the function on one of the texts, I get an error that the list of my matches is empty but the text actually contains a gene.