Create, verify and visualize regular expressions with iHateRegex - gHacks Tech News

ADVERTISEMENT

Create, verify and visualize regular expressions with iHateRegex

Regular expressions, or regex, can be very powerful when it comes to find operations provided that programs or online services support them. Programs like TextConverter, PowerRename, or nnn support regular expressions, but using regular expressions can be intimidating or outright frustrating.

Take the following expression as an example: (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}. If you are familiar with regular expressions, you may understand the expression right away. If you are not, you may have a hard time deciphering it (it detects IP addresses).

Crafting regular expressions can be very frustrating especially for users who just started to learn regular expressions.

The new website iHateRegex comes to the rescue. The site maintains a searchable database of regular expressions and includes a playground for testing regular expressions.

regular expressions tester

The search field on the project's startpage can be used to search the database of regular expressions. Select any to display the expression, example matches, and a visualization that highlights the expression's flow.

You can edit any of the regular expressions or example strings right away; results and the visualization are updated in real-time and it is quite easy to use the visualization and the matches to craft and verify regular expressions.

The playground works identical only that you are starting with a basic regular expression and visualization that you may modify to your liking. You may copy the expression or copy embed code, and even submit a new regular expression for evaluation and inclusion in the project's database.

Since you may edit any regular expression, you may also use copy and paste to copy regular expressions from other sites or applications to paste them on the iHateRegex site; this way, it is easy to edit, test and verify regular expressions.

Closing Words

There are plenty of sites on the Internet and programs that help understand, create and verify regular expressions. We reviewed the Windows software Regular Expression Coach in 2009 and it works to this day.

If there is one downside to iHateRegex it is the fact that you cannot just use the site if you are getting started. You need another resource such as Regexr or regular-expressions.info to learn the basics quickly. It would be great if the developer of the site would add some tutorials and quick help options to the site to assist users.

Now you: have you used regular expressions before?

Summary
Create, verify and visualize regular expressions with iHateRegex
Article Name
Create, verify and visualize regular expressions with iHateRegex
Description
A review of the site iHateRegex which provides a database of regular expressions, and tools to craft, test, and visualize regular expressions.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Previous Post: «
Next Post: »

Comments

  1. John Fenderson said on February 3, 2020 at 7:15 pm
    Reply

    I seriously love regular expressions, but I understand why others don’t. This website is a very nice compilation of common regular expressions! I may love regex, but I also approve of iHateRegex.

    1. pd said on February 5, 2020 at 3:28 am
      Reply

      I’m so very glad you added the second sentence. After the first sentence, I felt sure I needed to add you to my “dark side” / “avoid at all costs” list, LOL (actually, I’m only half joking/serious!).

  2. Odin said on February 3, 2020 at 7:27 pm
    Reply

    Thanks! My go-to used to be regexr.com but I ran into problems with certain limitations that tool has. E.g it doesn’t support lookbehind. iHateRegex seems to support most if not all expressions.

  3. Geon George said on February 3, 2020 at 7:29 pm
    Reply

    Thank you for sharing. I’m the creator of ihateregex

  4. Clairvaux said on February 3, 2020 at 9:22 pm
    Reply

    Just looking at this flowchart makes me hate Regex even more. I did not think it was that complicated. But thanks for the commendable effort…

    1. John Fenderson said on February 3, 2020 at 9:57 pm
      Reply

      @Clairvaux:

      Regular expressions are extremely complex. That’s both a blessing and a curse. Fortunately, at least 90% of the time you can ignore the really complex parts.

      1. Clairvaux said on February 4, 2020 at 6:06 pm
        Reply

        @ John Fenderson

        Is there a de facto standard for search ? The way Ctrl+A or Ctrl+C are more or less standard ?

        All programs seem to have different rules. This is very annoying.

    2. pd said on February 5, 2020 at 3:36 am
      Reply

      I agree the flow charts are a bit intimidating but maybe try to take them with a grain of salt and see the site as more of a testbed service?

      Also, my own tip for regex? There’s not necessarily one single universal syntax. There’s Perl-Compatible Regular Expressions (PCRE) for example, but there’s others as well. Sucks, I know. But sucks more when you think you’re getting the syntax right only to realise the syntax is generically correct but not specifically correct for the regex engine context you’re using.

      I personally have found the regex syntax in JS particularly annoying. Not so much writing the actual patterns but the syntax of the methods and such. It’s either really simple (using .match(), on a string) or messy (requiring a full setup of a new RegExp instance).

  5. Gabriel said on February 3, 2020 at 9:37 pm
    Reply

    Always been a user of Regexr although this looks like a nice alternative.

  6. Anonymous said on February 3, 2020 at 10:23 pm
    Reply

    this, but offline pls

  7. Herman Cost said on February 3, 2020 at 11:29 pm
    Reply

    The anti adblock message on this site is gone (at least on my computer). That was a pleasant surprise.

  8. Masiqonde said on February 4, 2020 at 4:04 am
    Reply

    Ilike this app but with common regular expressions I HateRegex

  9. KarlsonD said on February 4, 2020 at 4:05 am
    Reply

    “WildGem is a small, free, lightning-fast, portable, single-file app for Windows to help find and replace text. Its powerful syntax combines most of the flexibility of Regex, but with the simplicity of the typical find/replace feature found in your text editor or word processor.

    Unlike similar programs, WildGem is fast with a dual split display, and updates or highlights matches as you type in realtime. A unique colour coded syntax allows you to easily find/replace text without worrying about having to escape special symbols.

    If you’re a beginner who only occasionally uses find and replace, WildGem will feel second-nature, and can even help you to formulate queries with wildcards.

    If you’re moderately competent with basic or extended expressions, but rarely use Regex, WildGem will allow to create more powerful expressions more quickly with its intuitive interface. Individual WildGem symbols can replace the equivalent of up to 22 Regex symbols!

    If you’re an expert with Regex and use it all the time, you may still appreciate the simpler syntax, colour coding, lightning speed, large input/output areas, realtime updating as you type, and the feature which converts your expression into the equivalent Regex syntax.”

    Although primarily an S&R app, it can be used to learn regex and test what you’ve written.

    http://www.skytopia.com/software/wildgem/

    1. pd said on February 5, 2020 at 3:39 am
      Reply

      Looks like an interesting option.

      Thanks!

  10. thebrowser said on February 4, 2020 at 6:37 am
    Reply

    Excellent resource, we can never have enough of these to help us with the trouble of regex. I’ve used them a few times in the past and while it was fun to learn and build a project around it, it’s definitely not something I’d like to work on continuously!

    Thanks for the article Martin

  11. Anonymous said on February 4, 2020 at 7:27 am
    Reply

    Provide another website
    https://jex.im/regulex/

    1. Tom Hawack said on February 4, 2020 at 12:52 pm
      Reply

      @Anonymous, thanks for the link; that site provides an immediate regex expression visualizer which is providential for users as myself who aim only to understand a given regex with no hope to ever develop one of their own… these expressions are so complicated for the newbie.

      1. pd said on February 5, 2020 at 4:03 am
        Reply

        Hey Tom. I do not know you but I’d just like to say I’m certain there’s every hope you can develop your own. Why? I was in the same headspace as you for a long time. I’m no regex guru now but I’m thankfully more or less beyond the “can’t do it, I’m not smart enough” stage you are in.

        Small steps my friend! Start with the simpler stuff. Ignore trapping or catching patterns to re-use in the replacement, for example. Also understand that everyone, perhaps excluding those arguably on the spectrum, struggle at times to work on a specific task. Helps to break it down and that’s why tools like this one exist.

        Best of luck!

      2. Tom Hawack said on February 5, 2020 at 11:37 pm
        Reply

        @pd, thanks for bringing hope throughout your similar experience which you’ve challenged successfully. I believe there’s a part of laziness in resignation and I do agree that there’s space for will and determination before accepting a defeat on solid grounds. Intelligence counts but in the same way we believe we need to surface for air when swimming under water when actually we have enough in the lungs to carry on longer, in the same way we have enough in the brains to understand far more than we might think we’re able of. Yet, there is a limit :=) and knowing that limit is as valuable as underestimating it (otherwise we may definitely get hurt!).

        I just have to get myself swimming a bit more, at least. Why would i doubt?!
        I like the way you said it, reminds me my youth in the States, I mean the cultural environment.

  12. C Sharp fan said on February 4, 2020 at 8:40 am
    Reply

    Thanks for this tip Martin.

    I once had a job where I needed to make some rather complex regular expression code.

    I thought it would be easy, as I had some examples that did similar to what I needed, so I had thought.

    I studied but my progress was at best very slow. So, I ended up getting even more confused and just gave up.

    Then a few weeks later I tried again. This time I just used trial & error and ignored those examples, not knowing much of what I was doing, blindly hacking away… and I found what I needed and more in little time. My job was soon done, doing more than I expected!

    I got lucky.

    I still don’t see why it worked as I see no logic in it, but it still works like magic.

    That said, I can see where iHateRegex could help me next time, but I’d rather avoid a next time.

    1. pd said on February 5, 2020 at 4:07 am
      Reply

      Sounds like you had the barrier of being told what should work. Once you got into exploration mode and allowed yourself to try and/or fail, small steps at a time, that’s what made the difference.

      Psychologically this is a headspace I am all too familiar with. Would be great if someone gave it a name and we could perhaps all start trying to learn how to process such scenarios more easily.

      Congrats on your progress. Reggies can be like a freaky and scary subset of programming that we can all fear whilst having no trouble at all with the rest of a programming scenario / language. I speak from experience and a place of still regularly feeling like an imposter as a developer.

      1. C Sharp fan said on February 10, 2020 at 1:42 pm
        Reply

        @pd

        As our work and goals are often different, there are many names for various methods and mindsets, such as with “trial and error” which is closely related to what’s called Divergent Thinking.

        With a logical mindset, I first tried Convergent Thinking, yet that didn’t go well as that mindset expects that there is only one correct answer, as I had wrongly assumed.

        That said, if anything, I think taking that break helped the most, with relaxing and dreaming. In part, for lack of a better term, that may be considered what they call “psychological distance”? Regardless, such a mindset allows abstract thoughts to contemplate most anything. I think this type of mindset is usually best for innovating.

        When faced with a tough problem, Albert Einstein said it helped to take a break and play his violin.

        That said, as you may know, getting the right perspective of a problem is, well, a problem in itself.

        In my case, I don’t think I ever got the right perspective, but I did find a great solution.

        Still seems like dumb luck to me; a hole in one.

  13. peterdedonder said on February 4, 2020 at 2:25 pm
    Reply

    I’m a very satisfied regular user of https://regex101.com/
    A site that nicely explains the regex you write down and also has a brief but good documentation.

    1. Amonymous said on February 5, 2020 at 9:58 am
      Reply

      Yeah, the few times I have to use regex, the site is pretty good for testing out commands.

  14. Don said on February 4, 2020 at 5:12 pm
    Reply

    I’m an occasional user of RegexBuddy. Full featured and complex. It helps me learn by letting me tweak the regex and see the results instantly. It uses outlines and color to help make sense of a regex. There are many flavors of regex and this app mimics many of them.

    The visualization at iHateRegex is the main feature. But I’m unsure if it really helps. I need to play with it more.

  15. Peterc said on February 4, 2020 at 7:46 pm
    Reply

    The sheer dauntingness, complexity, and “alien” nature of regular expressions to RegEx noobs like me is the whole reason “Alternative Find & Replace for Writer” (aka “AltSearch”) is an *essential* extension for most LibreOffice users. I know I would resent having to research RegEx for the only *slightly* non-plain-vanilla searches I sometimes do in Writer. Ask yourself: if you don’t use regular expressions on a regular basis (no pun intended), are you *really* going to remember everything you learn about them? Or are you going to have to “refresh your recollection” pretty much *every time you use them*? I know what the answer is for me, and it’s not flattering.

    In Windows, RegEx is an optional alternative search syntax for the “Everything” desktop file search utility, and it’s also the very first (and most potentially granular) field pair in “Bulk Rename Utility.” Plus, I gather it’s the standard for search and replace operations in Unix-based systems (Linux, BSD). So — regular expressions are clearly worth becoming familiar with. (I feel discouraged just *thinking* about it. ;-)

    Anyway, I really appreciate this article and the resources mentioned, in the comments as well as in the article itself. I’ve already had to directly code regular expressions a couple of times and will undoubtedly have to do so again in the future — especially in Linux — and I’ll come back here when I do.

  16. Cor said on February 6, 2020 at 1:40 pm
    Reply

    Thanks. voidtools’ Everything has a tiny cheat sheet in its “Help” which I’m regularly using.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.