Skip to content

Tag: python-re

removing URL from string using python’s re

Using this to try to remove URLs from a string: Unfortunately it works for simple URLs but not for complex ones. So something like http://www.example.com/somestuff.html will be removed but something like http://www.example.com/somestuff.html?query=python etc. will just leave trailing bits behind. I think I&#8…

How to re.search module on python

In a part of my program, I have to check an email entered and I want to make it so any domain name can work for the checker, current code as below; Currently, this will work for any email in for example@email.com but as some emails are in the form example@email.co.uk so how can I can make ’emailFormat&#…

Question on regex not performing as expected

I am trying to change the suffixes of companies such that they are all in a common pattern such as Limited, Limiteed all to LTD. Here is my code: I’m trying ‘ABC CORPORATN’ and it’s not converting it to CORP. I can’t see what the issue is. Any help would be great. Edit: I have tr…

groupdict in regex

I have the following string: I wrote a regex for this which will find the first-name and last-name of user: Result: Sometimes, I don’t get the last name. At that time, my regex fails. Can any one have any idea regarding this? Answer You may use See the regex demo Regex details ^ – start of string …