4 ms·
I only really learned it by having a problem to solve. You have to be careful with runtime costs, but I often use it to get machine readable info from logfiles.
by raxxorraxor 4y ago
I only really learned it by having a problem to solve. You have to be careful with runtime costs, but I often use it to get machine readable info from logfiles.
Also https://regexcrossword.com/ https://regexcrossword.com/ is pretty fun.
Sometimes I just need to grab all public IPs from AWS stuff to whitelist them for something. With Windows powershell for example, although the regex here is crude and would match non-valid IPv4 adresses, it is enough for logfiles:
$awsIPs = aws ec2 describe-network-interfaces --output=text | Select-String -Pattern ("ASSOCIATION.*\s(([0-9]{1,3}\.){1,3}[0-9]{1,3}$)") | ForEach-Object { $_.Matches.Groups[1].Value } | Select-Object -Unique
Within apps I use them mostly to cut small strings into the respective parts if a simple split doesn't work. I do use them to validate user input regularly, although I don't do user interfaces that often. Not a web developer, but in JavaScript I use them quite often.
I still have to look up some rules from time to time.
For designing the regex I often use sites like this: https://regex101.com/ https://regex101.com/ Here you also get a handy reference and error description.