12

Many questions about regex include code blocks with language agnostic, POSIX compatible patterns, using default prettifying. (example)

free hand circle is best

This looks kind of ugly and is confusing, since some parts are marked as literals.

How should regex code be handled? Should syntax highlighting just be disabled for regex using lang-none? I think correct syntax highlighting could improve it's readability, just by marking meta-characters and escaped meta-characters.

Including a language tag results in a different highlighting and seems superfluous when talking about POSIX regex - maybe even obstructive, since most people don't want to read questions about your . Including a language tag and using a full line of code, like String pattern = "[a-z0-9]+"; wouldn't add any valuable information. It would only get rid of the random highlights by showing the whole pattern as literal, so no advantage over disabling highlighting completely. Of course including a language tag has its advantage though and a new feature should wait imho until it is clear that a question's language tag hasn't just been forgotten.

  • 1
    Yeah. Ick. I tried several of the language hints & didn't find any that really improved matters. – M. Tibbits Aug 26 '11 at 8:32
7

I think you'd need to submit a language filter to Google Code Prettify.

There is no lang-regex there yet.. but there could be if someone contributed one!

  • I took a look of the source and found that there actually is a lang-regex (Noticed it because I got some error when trying to create a filter with that name a few days ago). It seems it is used as part of a few languages supporting expressions enclosed in slashes, so it is not a full language and doesn't style anything. Along there is a TODO: maybe style special characters inside a regexp as punctuation.. A real lang-regex can probably even replace that. I'll experiment with it. – kapex Sep 1 '11 at 10:21
  • excellent; the author of Google Code Prettify is also semi-active here as a user too: meta.stackoverflow.com/users/137403/mike-samuel – Jeff Atwood Sep 1 '11 at 10:27

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