Looking at the list, I see that there is no language code for regular expressions, but I wondered if there was a language tag which would give good highlighting for regex's anyway (perhaps one with first-class support for regular expressions, like Perl). Is there?

Ideally I'd like a regex .*(capturingGroup)[a-z]{1,10} to be highlighted something like this:

enter image description here

  • 5
    Since most regex questions need a language tag as the implementation varies between languages, the syntax highlighting should be picked up by that language's highlighting. Is this not sufficient? – psubsee2003 Sep 19 '13 at 9:26
  • 3
    When posting a regex on its own (i.e. not in a code snippet), the language syntax highlighting is useless for every tag I've seen. In Java for example regex's are always in a String, so code highlighting doesn't handle them at all. Ideally capturing groups etc. would be highlighted, like on regexpal.com – MikeFHay Sep 19 '13 at 9:33
  • Instead of syntax high-lightening, Why don't we implement a feature similar to JSFiddle. For example regexplained.co.uk (for javascript) This would better than highlight right? – Praveen Sep 19 '13 at 12:38
  • The thing about "posting a regex on its own" is that "regex" does not actually specify the language you are using. These things come in umpteen different flavors, and though only a few of those make up the bulk of the actually uses there are still a few of them. – dmckee --- ex-moderator kitten Sep 19 '13 at 23:37
  • How about writing regular expressions in expanded form if they’re that complicated? – Ry- Sep 25 '13 at 16:50

I think we can do without every character of every code snippet being rendered in garish colours, as if we were filling up a Kindergarten display wall.

If you are a regex newbie and need to learn to read the expression, you can go to one of those websites like http://regexpal.com or http://regexplained.co.uk; for the rest of us, plain text is fine, thank you very much!

  • 5
    I'm just trying to imagine the regexes required to properly apply syntax highlighting to regexes... – Andrew Barber Sep 25 '13 at 16:45
  • 4
    @AndrewBarber: Yo, dawg... – Lightness Races in Orbit Sep 25 '13 at 16:51

This might not provide syntax highlighting, but it provides a nice visual representation and a nice "embedding" function for Stack Overflow.


It looks like this (this is an example from one of my actual answers) :

Regular expression image

Edit live on Debuggex

So all you have to do is just put the "non-colored" regex over or under and it gives a pretty good visual representation of that regex.

(In that case it was ^\d+(,\d+)*$)

Disclaimer : I'm not part of the debuggex project. I am just a user of it, and since I find it is an awesome tool, I decided to show it here.

Not the answer you're looking for? Browse other questions tagged .