Комментарии:
About raw strings: it is not true that you'd have to escape \d.
>>> re.search('\d', '1')
<_sre.SRE_Match object; span=(0, 1), match='1'>
However, you'd need a raw to avoid escaping group references like \1
>>> re.search('(\d)\1', '11') # tries to match character \u0001
>>> re.search(r'(\d)\1', '11')
<_sre.SRE_Match object; span=(0, 2), match='11'>
>>> re.search('(\d)\\1', '11')
<_sre.SRE_Match object; span=(0, 2), match='11'>
There is a project that does the opposite of what you mentioned: given a list of strings, they produce a regex that matches them all (and isn't just a big OR of them all). Can't remember the name, though.
nice dude !! , got me into programming and python .. thanks to " how to automate the boring stuff"
ОтветитьRegex has always scared the stink out of me ever since I saw my first regex string years and years ago. Thanks for holding the listener's hand through this.
ОтветитьThank you very much Bro. I learned RegEX from you.
ОтветитьShouldn't we be careful to distinguish between slashes and backslashes?
Ответитьi've been learning from this book and i was being ok with the fundamentals but Regex literally got me stuck and frustrated big times. kinda boring and unmotivated to learn it but indeed this is what's really useful in real life..
ОтветитьMicrosoft has a proprietary tool called RobustFill that can learn regexes from examples. It is better than all such tools before it. It is not free or open-source. There is however a technical publication associated with it on Arxiv, and it appears to be reproducible.
ОтветитьThe “live demo” god.
Ответитьat last a way to understand the damned htaccess file!!! thanks!!
Ответитьbut idunno if i can handle another problem...
ОтветитьRegex is a pain not because it's difficult to learn (because it's not and it's quite easy actually), but because different languages have some slight variations in the regex syntax rules.
Why do programmers like to add to the messiness of the whole world of regex flavors is really a mystery.
In video he says that
I cannot write a regex to find out the other regex is valid or not?
Not bad, but some mistakes. Special characters lose their special meaning inside sets. For example, [(+*)] will match any of the literal characters '(', '+', '*', or ')'
ОтветитьWatching this video for the 15th or 20th time. YOU Sir, your way of giving talk, got me started on teaching python. Thank you.
Ответитьgreat
ОтветитьIt's kind of bullshit that the letter Y isn't a vowel.
Like common, how is Y not a vowel.
Idea for that project:
Take the regex and build a DFA. Of course, you'd have to first make an NFA and then convert it to a DFA. A DFA is a graph with a single start and potentially multiple but at least one final state. So, you can start at the start state and traverse the edges using a path finding algorithm between two nodes of a graph until you get to the some final state, outputting the characters that label the edges along the way. This will give you a string accepted by the regex. It won't be fast but I'm pretty sure it will work.
Al Sweigart always has great talks. Thanks Al!!!!!
Ответить