Skip to content
Advertisement

Tag: regex

Delete digits in Python (Regex)

I’m trying to delete all digits from a string. However the next code deletes as well digits contained in any word, and obviously I don’t want that. I’ve been trying many regular expressions with no success. Thanks! Result: This must not b deletd, but the number at the end yes Answer Add a space before the d+. Edit: After looking

Find Hyperlinks in Text using Python (twitter related)

How can I parse text and find all instances of hyperlinks with a string? The hyperlink will not be in the html format of <a href=”http://test.com”>test</a> but just http://test.com Secondly, I would like to then convert the original string and replace all instances of hyperlinks into clickable html hyperlinks. I found an example in this thread: Easiest way to convert

Python re.findall with groupdicts

I kind of wish that there were a version of re.findall that returned groupdicts instead of just groups. Am I missing some simple way to accomplish the same result? Does anybody know of a reason that this function doesn’t exist? Answer You could use the finditer() function. This will give you a sequence of match objects, so you can get

What is the difference between re.search and re.match?

What is the difference between the search() and match() functions in the Python re module? I’ve read the Python 2 documentation (Python 3 documentation), but I never seem to remember it. I keep having to look it up and re-learn it. I’m hoping that someone will answer it clearly with examples so that (perhaps) it will stick in my head.

Advertisement