regex" class. You can see an example of doing just that on my quick and dirty test page.
24 thoughts on “Regex Syntax Highlighter”
You know what I really want from RegexPal? Some replace features. Whenever I have to do a quick replace I’ve been hitting up http://www.regextester.com/ but it’s not nearly as nice as RegexPal.
Except for the fact that it does replacement.
Can’t imagine it would be that hard to implement and I’ll totally hook you up with some Mountain Dew and a pack of cigarettes next time I see you.
Tsk tsk, William. Define “that hard to implement.” 😛
To do it right, it would require two new fields–one for replacement text (which would need its own dedicated replacement-text-syntax highlighting) and a read-only field to store the result. With two new multiline textareas, things would start to get a bit cluttered (IMO, part of the appeal of RegexPal is its simplicity and its large regex and subject text textareas). Hence, in order to avoid unnecessary clutter when its not needed, you’d need to be able to easily switch between match mode (two fields) and replace mode (four fields). I would also want to highlight replacements in the replacement result similar to matches in the subject text, to help users quickly identify what changed. Then it might be helpful to add a way to quickly transfer the replacement result to the subject text textarea. Keeping in the spirit of RegexPal might also require the replacement result to be updated automatically as you type. But then, that might be annoying sometimes, so an option would be needed to turn off automatic updating. And so on…
I’d like to add replacement functionality, but unfortunately it would take more work than I’m able to dedicate to it in the near future. (I’d rather keep RegexPal simple and elegant than half-ass replacement features.)
Yeah, I hadn’t envisioned hacking up the RegexPal UI. I’m sure you’ve heard of tabs. 😉 Or a simple toggle switch at the top.
Real-time would be nice but I’d be happy with a pretty simple replace.
great work man!
you should put this on github!
I couldn’t find your email address anywhere on your website, so I’m just gonna write it here. Thank you for http://regexpal.com/ – it’s ****ing awesome and works like a charm.
If your interested in checking it out, I’ve released my script as open source. It doesn’t have all the cool syntax error checking that your has, but I think it does fill another niche:
Thanks for this great blog – you have a new fan!
I’ve updated my dynamic highlighting script so that it is now compatible with Steve’e colorizing script. I think its pretty cool.
Check it out: Dynamic Regex Highlighter
Well, I found a use for the highlighting scripts. I just finished reviewing all the regexes in jQuery and wrote an article describing some proposed improvements.
Check it out: jQuery Regular Expressions Review
Bug report: If one has a regex which is matching an html entity string (e.g. the entity for a left angle bracket: ‘
/</‘), this needs to be be encoded on the web page in the .regex element as ‘
/&lt;/‘ to be valid HTML. But after being processed by jsresyntaxhighlighter.js, this will be displayed as: ‘/</'.
The culprit is this code at the top of jsresyntaxhighlighter.js:
value = compressHtmlEntities(value);
This compresses: ‘
&lt;‘ down to: ‘
<‘ which then erroneously becomes ‘
<‘ when it is later passed through expandHtmlEntities(). I don’t think this initial call to compressHtmlEntities() is really necessary – is it?
Great job man.
Thanks for your online tool of Regular expression check http://regexpal.com.
It is amazing site for check regular expression online.
Again thank you Very much.
it help me a lot.
I am passing along a possible bug I may have found. If the string to match on is:
Maybe I’m misinformed, but I expected the following expressions to produce the same results:
The second, unfortunately, misses the last letter. Otherwise, great tool!
That’s awesome – great job, thanks.
I had an xml file with certain tag
<xyz> 1800 < 3944877 </xyz>
in this the less than sign is causing problem to read the xml file so I was thinking to use regex to find the less than sign and replace it.
I am using c#
Can any tell me the regex or is there any other way i can do it
I write this :
but it holds good till each tag is separated with new line.
Is XRegExp broken with jQuery 1.7.1. If I plugin your example text from the API page, I don’t get the same output that you do. In fact, nothing changes when I try to use an XRegExp.replace….Any help would be greatly appreciated.
Just wanted to say great work with regexppal. It’s a really helpful tool. Thanks for letting everyone use it!
@Jason, I’d need to see example code to troubleshoot. XRegExp 1.5.1 and later should work just fine with jQuery 1.7.1. (XRegExp 1.5.0 had an edge case IE bug with jQuery 1.7.1, but what you wrote doesn’t sound like the same thing.)
@ridgerunner Was just checking out your project again. ‘Tis tres cool, and I’m hoping to look into using it in future versions of RegexPal. Are you on Twitter? Here’s my recent Twitter shout-out: https://twitter.com/slevithan/status/180851694668746753
I’ve just updated this script to v0.2, and renamed it as Regex Colorizer. The new version includes API changes, no longer relies on a separate CSS file, and adds syntax error descriptions as
titletext. This library is also now available via GitHub.
Reference documentation and SDK here:
@Dan-el, that’s great! However, note that you’re commenting on a blog post that has nothing to do with XRegExp. I’ve therefore mentioned it on Twitter. Also note that it looks like you’ve inappropriately added the
XRegExp.prototypeinstance methods provided by the XRegExp Prototypes addon (
xtest, etc.) as if they were methods of the
XRegExpobject, which they are not.
Could you update the demo link? Thanks!