Aug-08-2022, 07:47 AM
(Aug-08-2022, 12:44 AM)kucingkembar Wrote: anyway is there any regex tutorial with lots of example?
Even reading the posts here, in this Forum site, you'll find a tonne of Regex info, but (IMHO) Regex is over used. A good rule of thumb (again, IMHO) is that if you know what you're looking for, then it's not pattern matching, so why use Regex.
Four digits between zero and nine, back-to-back (such as a Year, 2022), in a string object, is pattern matching:
re.search('[0-9][0-9][0-9][0-9]', dateString)
as that will find any four digit number, but finding specifically the year 2022 in a string, is not pattern matching; you know what you're looking for, so I'd say the same thing with your issue: you know what you're looking for (square brackets), so it's not pattern matching.
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein