How to check your RegExps in IntelliJ IDEA 11?

In IntelliJ IDEA 11 you can check your Regular Expressions while coding without leaving the IDE. Just invoke the ‘Check RegExp’ intention action on a regular expression and play!

Tip: You can turn any string into a regular expression by injecting RegExp language. Try the ‘Inject Language’ intention action.

This entry was posted in New Features and tagged , , . Bookmark the permalink.

22 Responses to How to check your RegExps in IntelliJ IDEA 11?

  1. Joe says:

    Even better would be to see how the groups of the regexp apply to the sample text.

  2. Stephen Friedrich says:

    Is this supposed to work in 110.291?
    The popup is so small that the “Sample” field is invisible.

    +1 for support for groups.

  3. Joachim Arrasz says:

    This is just awesome!!!

  4. @Stephen Popup autoresizes when needed.
    @Joe you mean show all groups below the Sample text box?

  5. Ingo says:

    Great feature, also +1 for groups!

  6. xBlackCat says:

    Autoresize is not working.

    I’ve open two projects and after the popup is shown the focus moves to second project and all typed letters are appeared in the second project editor.

    Please, prevent input field from collapsing.

    +1 for show group captures.
    I prefer to see matched group strings at the right of popup component as string.

    May be it is better to replace popup hint with dialog. Or move testing regex to pane (like it was in RegexPlugin http://plugins.jetbrains.net/plugin/?id=19)

  7. m.milicevic says:

    I have same issue as Stephen, no way I can resize nor access example field :( I just see a small line. Probably because I changed application default font or something (I am on linux, gnome if that matters)

  8. magicprinc says:

    +1 for RegexpPlugin – very good plugin

  9. Brice says:

    Agreed, this is just super neat!

  10. Brice says:

    By the way did you remove the Java regex constructs from the autocompletion popup in Jvascript regexes. http://youtrack.jetbrains.net/issue/IDEA-70998

    (This behaviour might be present for other language.)

  11. Mark says:

    Nice feature. Unfortunately I am also not seeing the sample text field.

    Charles opened a YouTrack for that issue:
    http://youtrack.jetbrains.net/issue/IDEA-76512

  12. Ivan says:

    Look very helpfull! I’ll try to implement it in vs2011 as add-in.

  13. Mike says:

    How do you trigger this to appear? Pressing alt-enter on a regex doesn’t offer an option to bring this up (using 110.365).

  14. Hello Mike, do you have IntelliLang plugin enabled? It’s enabled by default.

  15. @Mark, thanks. Fixed. Balloon was too close to top border – what’s the reason it changed its size

  16. Mike says:

    I do indeed have the IntelliLan plugin enabled and the intention won’t appear. However, I should point out that the RegEx is in Groovy code. I will try it in Java code and see what happens.

  17. Ryuu says:

    @Mike: also in groovy regexp (e.g.: /[0-9]*/) works. You have to inject “RegExp” language to the string.

  18. Viraf Karai says:

    Yes – I too tried this in Groovy code and there are no issues.
    Here’s some sample code that works:

    def emailAds = “somebody@somewhere.com”
    boolean regexMatch = emailAds.matches(“s[a-z]+@[a-z]+.com”)
    println “Regex matches: ${regexMatch}”

    * Highlight the regex above ie. s[a-z]….. (excluding the quotes)
    * Hit Alt-Enter and inject the RegExp language against that regexp.
    * Highlight that same regexp above (excluding the open and close
    quotes)
    * Right click and select Check RegExp.
    * You should now see the popup against which you check your regexps.
    It’s truly a beautiful thing.

    Kudos a hundred times over to Dmitry and the JetBrains team. Brilliant job and extremely usable.

  19. Joseph says:

    I have Intellij idea 11.1.3 ultimate edition and there ain’t no Check RegExp intention among available intentions. How’s that ?

  20. Andreas says:

    Very nice Plugin, but it would even nicer, if one could resize the pop up window und enter multiline samples.
    Als a visual feedback for group matching would be really nice.

    I know, I am completely indulged by the existing eclipse reg exp plugins ;)

  21. Nami says:

    Hey, seems like this doesn’t recognizes some regepxs, ie in RubyMine it never matches regexps with ? syntax.

  22. Nami says:

    Seems there’s already an issue for that ! http://youtrack.jetbrains.com/issue/IDEA-94963

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">