regex-greedy

Set a multichoice regex to make its matching attempts always from left to right, no matter if another previous regex tries to capture more chars?

Set a multichoice regex to make its matching attempts always from left to right, no matter if another previous regex tries to capture more chars? Question: import re input_text = ‘el dia corrimos juntas hasta el 11° nivel de aquella montaña hasta el 2022_-_12_-_13’ #input_text = ‘desde el corrimos juntas hasta el 11° nivel de …

Total answers: 1

Regular Expression, using non-greedy to catch optional string

Regular Expression, using non-greedy to catch optional string Question: I am parsing the content of a PDF with PDFMiner and sometimes, there is a line that is present and other time not. I am trying to express the optional line without any success. Here is a piece of code that shows the problem: #!/usr/bin/python3 # …

Total answers: 1

use regex to extract multiple strings following certain pattern

use regex to extract multiple strings following certain pattern Question: I have a long string like this and I want to extract all items after Invalid items, so I expect regex returns a list like [‘abc.def.com’, ‘bar123’, ‘hello’, ‘world’, ‘1212’, ‘5566’, ‘aaaa’] I tried using this pattern but it gives me one group per match …

Total answers: 3

RegEx for extracting domains and subdomains

RegEx for extracting domains and subdomains Question: I’m trying to strip a bunch of websites down to their domain names i.e: https://www.facebook.org/hello becomes facebook.org. I’m using the regex pattern finder: (https?://)?([wW]{3}.)?([w]*.w*)([/w]*) This catches most cases but occasionally there will be websites such as: http://www.xxxx.wordpress.com/hello which I want to strip to xxxx.wordpress.com. How can I identify …

Total answers: 4

Python non-greedy regexes

Python non-greedy regexes Question: How do I make a python regex like “(.*)” such that, given “a (b) c (d) e” python matches “b” instead of “b) c (d”? I know that I can use “[^)]” instead of “.”, but I’m looking for a more general solution that keeps my regex a little cleaner. Is …

Total answers: 7