Software Alternatives & Reviews

Ask HN: Does anyone here truly, know Regex?

regular expressions 101 Regex Crossword
  1. Extensive regex tester and debugger with highlighting for PHP, PCRE, Python and JavaScript.
    Yes people truly understand regex. It is a solidly and quite completely explored art of computer science. This is not an area of learning how to "code" via examples. This is an area that requires the study of computer science, aka math. If you find regex confusing, it means that you do not understand or have not learned about, some fundamental principles of computer science - regular languages, finite state machines, and regular expressions. This is <i>not</i> intended to be derisive. It's just a very, very common issue - regular expressions are like the algebra and calculus of computer science. It looks like magic if you don't understand it, but it's not magic - it's obvious if you learn the background. You can code a lot of code without knowing computer science. But you will not learn regular expressions that way. Another +1 for https://regex101.com, btw.

    #Regular Expressions #Programming Tools #Productivity 868 social mentions

  2. Welcome to the fantastic world of nerdy regex fun!
    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/ 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: <pre><code> $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.

    #Regular Expressions #Programming Tools #Free Games 65 social mentions

Discuss: Ask HN: Does anyone here truly, know Regex?

Log in or Post with