# Syntax highlighting for regexp

**URL:** <https://www.ruby-forum.com/t/syntax-highlighting-for-regexp/125873>\
**Category:** Ruby\
**Created:** [January 13, 2008, 6:13am UTC](https://www.ruby-forum.com/t/syntax-highlighting-for-regexp/125873 "2008-01-13T06:13:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_DeLorme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9d8465/32.png) [@Daniel\_DeLorme](https://www.ruby-forum.com/u/Daniel_DeLorme)\
**Post date:** [January 13, 2008, 6:13am UTC](https://www.ruby-forum.com/t/syntax-highlighting-for-regexp/125873/1 "2008-01-13T06:13:23Z")

</div>

We all now regular expressions can be difficult to read, but it seems to  
me like good syntax highlighting _within_ a regexp would make the task  
much easier. Even something as simple as a different color for control  
characters vs literals. Is there an editor which does that?

Daniel

---

<div class="post-metadata">

**Author:** ![Daniel\_DeLorme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9d8465/32.png) [@Daniel\_DeLorme](https://www.ruby-forum.com/u/Daniel_DeLorme)\
**Post date:** [January 13, 2008, 6:22am UTC](https://www.ruby-forum.com/t/syntax-highlighting-for-regexp/125873/2 "2008-01-13T06:22:08Z")

</div>

You can check out The Regex Coach [1] on Windows to help develop regular  
expressions although it will not do syntax highlighting in your editor.

Dan

[1] [The Regex Coach - interactive regular expressions](http://www.weitz.de/regex-coach/)

---

<div class="post-metadata">

**Author:** ![Daniel\_DeLorme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9d8465/32.png) [@Daniel\_DeLorme](https://www.ruby-forum.com/u/Daniel_DeLorme)\
**Post date:** [January 13, 2008, 6:25am UTC](https://www.ruby-forum.com/t/syntax-highlighting-for-regexp/125873/3 "2008-01-13T06:25:04Z")

</div>

On Jan 12, 2008, at 21:12 , Daniel DeLorme wrote:

> We all now regular expressions can be difficult to read

Well… I find your English harder to read than my regexps. 😛

---

<div class="post-metadata">

**Author:** ![Daniel\_DeLorme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9d8465/32.png) [@Daniel\_DeLorme](https://www.ruby-forum.com/u/Daniel_DeLorme)\
**Post date:** [January 13, 2008, 12:10pm UTC](https://www.ruby-forum.com/t/syntax-highlighting-for-regexp/125873/4 "2008-01-13T12:10:39Z")

</div>

On 13.01.2008 06:12, Daniel DeLorme wrote:

> We all now regular expressions can be difficult to read, but it seems to  
> me like good syntax highlighting _within_ a regexp would make the task  
> much easier. Even something as simple as a different color for control  
> characters vs literals. Is there an editor which does that?

I do not know one off the top of my head but various editors allow to  
jump to matching brackets or highlight the expression between two  
matching brackets. There is also option /x which allows for nice  
regular expression formatting (including comments).

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![Daniel\_DeLorme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9d8465/32.png) [@Daniel\_DeLorme](https://www.ruby-forum.com/u/Daniel_DeLorme)\
**Post date:** [January 13, 2008, 5:18pm UTC](https://www.ruby-forum.com/t/syntax-highlighting-for-regexp/125873/5 "2008-01-13T17:18:45Z")

</div>

Thanks for the answers but what I was looking for what really syntax  
highlighting within my editor, not a visual tool for building regex. I  
don’t know if this is a common view, but I find regex are usually easier  
to write than to read.

After messing around a little, I managed to find how to hack jEdit’s  
syntax highlighting for ruby, so I went and added what I wanted. I’m  
decently pleased with the results. I’m attaching the resulting syntax  
file, in case anyone is interested. Based on jEdit 4.2, it should  
replace the file /usr/share/jedit/modes/ruby.xml

Daniel

---

<div class="post-metadata">

**Author:** ![Daniel\_DeLorme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9d8465/32.png) [@Daniel\_DeLorme](https://www.ruby-forum.com/u/Daniel_DeLorme)\
**Post date:** [January 14, 2008, 12:04am UTC](https://www.ruby-forum.com/t/syntax-highlighting-for-regexp/125873/6 "2008-01-14T00:04:19Z")

</div>

On Jan 12, 2008, at 9:12 PM, Daniel DeLorme wrote:

> We all now regular expressions can be difficult to read, but it  
> seems to me like good syntax highlighting _within_ a regexp would  
> make the task much easier. Even something as simple as a different  
> color for control characters vs literals. Is there an editor which  
> does that?
> 
> Daniel

Daniel-

This is not exactly a regex syntax highlighter but it is one of the  
coolest regex tools I’v ever seen. It’s an animated state machine  
chart based on regexes you paste in and you can see the state machine  
animate as it matches your string:

[http://osteele.com/tools/reanimator/](http://osteele.com/tools/reanimator/)

Cheers-

- Ezra Z.  
– Founder & Software Architect  
– removed\_email\_address@domain.invalid  
– [EngineYard.com](http://EngineYard.com)

---

<div class="post-metadata">

**Author:** ![Daniel\_DeLorme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9d8465/32.png) [@Daniel\_DeLorme](https://www.ruby-forum.com/u/Daniel_DeLorme)\
**Post date:** [January 13, 2008, 12:45pm UTC](https://www.ruby-forum.com/t/syntax-highlighting-for-regexp/125873/7 "2008-01-13T12:45:55Z")

</div>

On Jan 13, 6:12 am, Daniel DeLorme [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> We all now regular expressions can be difficult to read, but it seems to  
> me like good syntax highlighting _within_ a regexp would make the task  
> much easier. Even something as simple as a different color for control  
> characters vs literals. Is there an editor which does that?
> 
> Daniel

tkregexp : A Tcl Tk is available by Laurent Riesterer (salut  
Laurent !) :  
[Visual REGEXP : a graphical explorer for your regexps](http://laurent.riesterer.free.fr/regexp/)  
There is little difference between advanced tcl versus ruby regexp  
syntaxe, so perhaps is a good candidate for a TkRuby application  
exemple ?

PS. for those interested, there is a discution on the list:  
removed\_email\_address@domain.invalid

– Maurice
