Skip to main content

Posts

Showing posts from May, 2009

Moving from RegexHero.com to RegexHero.net

Why would anyone in their right mind switch from a nice .com to the less desirable .net domain extension? Well I came up with what I think is a good reason. Since Regex Hero is very specialized towards .NET regular expressions, I thought it'd be good for my search engine placement if I make the switch. Google will put fairly heavy emphasis on the domain itself and even the extension when considering keyword relevance. So if you search for "ASP.NET" you'll find www.asp.net is the first result. Likewise, I'm guessing that eventually my search engine placement for "regex .net" will be quite good. Of course I still own regexhero.com and if you go there you'll be instantly redirected to regexhero.net , so this switch shouldn't cause any broken links.

Animated Highlighting and New Settings

Animated Highlighting Ever since I first created Regex Hero there was one little thing that bothered me. If you made a change in your regular expression that didn't affect the highlighting, then it wasn't obvious that Regex Hero was updating automatically because nothing really changed visually. Well, now the highlighting will actually flash orange and then fade to yellow whenever it's updated. It's a little detail that I think helps provide better feedback to the user. CrLf Setting This is an extension of the work around carriage returns and line feeds I've done recently. The CrLf setting is configurable so Regex Hero will use carriage return/line feed combinations by default, or line feeds only if you wish. Real-time Highlighting Setting 9 times out of 10 I'd think most people would prefer the real-time highlighting that Regex Hero has always had. But in the rare case when you're dealing with massively complex regular expressions and/or target

Carriage Return/Line Feed Bug Fix

Apparently the change I made the other day caused a problem. Replacing carriage returns with line feeds has to be handled a little more carefully. I had forgotten that carriage returns are often paired with line feeds. This is an old Windows (DOS) formatted text standard. So if for example you copied some HTML from a text editor and pasted it into the target string, you'll most likely have both carriage returns and line feeds marking the end of every line. The problem then with what I was doing is that I end up with 2 line feeds for every line. That meant that in this scenario the highlighting for a match was shifted downward. The solution of course was to look for that carriage return/line feed combo first and replace it with a single line feed, and then replace any left over carriage returns after that. This solves the problem and once again makes Regex Hero a dependable tool to use for testing .NET regular expressions.

The Intricacies of Whitespace

A fellow user of the Regex Hero tool pointed out that the multiline option wasn't behaving as expected. In the following scenario with multiline turned on you'd expect every line to be highlighted: Regular expression: ^test$ Target string: test test test Well, as it turns out none of those lines were highlighted and I found out why. Apparently the .NET regex engine looks for the start of new lines based on line feeds rather than carriage returns. So behind the scenes I'm now replacing carriage returns with line feeds within both the regular expression and the target string. This solves the problem and allows multiline mode to behave more like it should. Thank you Ed for letting me know about this. The other little change I've made is concerning trailing whitespace. A co-worker pointed out that it's easy to overlook trailing whitespace in your regular expression. And since most of the time you're not going to purposely put spaces or carriage r

Unlimited Undos & Redos, and a Bug Fix

This was an interesting challenge, but I was able to get multiple undos & redos working in Regex Hero. So now you can press Ctrl+Z (undo) or Ctrl+Y (redo) within the tool, and you'll notice that each textbox has an infinite undo history. It's something I usually take for granted in most applications, but the Silverlight textboxes didn't support it natively so I had to write the functionality myself. It seems to be working pretty well now. While I was at it I also fixed a bug with the RightToLeft option within the tool. Before it would highlight the wrong text most of the time when you had the RightToLeft option turned on, but it's working now. I just had to reverse the order in which I build the highlighted text.

Replacement Strings

I've added the ability to use replacement strings within Regex Hero. Just click the "Replace" tab within the tool and you'll see what I mean. You'll notice that the layout changes when you click the "Match" or "Replace" tabs. I'm guessing that most users will simply want to use the matching functionality that has always been there. So I left "Match" as the default tab when you first bring up the tool.

Regex Error Details

Today I added regex error details to the tool. So now if you write an invalid regular expression, then you can mouse over the little box that pops up to see the complete error details. Hopefully it helps make it easier to figure out what's wrong with the regular expression.

Added number of matches found and fixed a scrolling issue

I added a little text block above the target string that'll show you the number of matches found. So you'll notice that when you first bring it up with Regex Hero highlighted, it simply says, "1 match found." It's such a simple thing, but I thought knowing this number might be useful. The next update is really a partial fix. Apparently there's a problem with the ScrollViewer in Silverlight 2.0 as documented here . Basically, when you try to put something extremely wide in the scroll viewer it'll all go crazy on you hiding and showing its contents sporadically. I fixed the problem by setting a max width on the text box of the target string. Unfortunately this means that the scroll bar won't take you to the very far left or right of extremely wide sections of text. You'll have to use your arrow keys for that. But it's better than what it was doing. Hopefully Silverlight 3.0 will solve this once and for all.

Revised Benchmarking

I noticed something when trying out the benchmarking feature today. It didn't seem to be any slower when matching ten results vs just one. So I knew something was up. After looking into it I still can't fully explain what was happening. Perhaps there was some lazy loading going on, I'm not sure. But I reworked the code today and it seems to scale properly now. It will slow down with more complex regular expressions, as well as target strings with more matches. For those who are curious about how I'm performing the benchmarking now, here's the code: Dim startTime As DateTime = Date.Now Dim _regexBenchmark As New Regex(strRegex, _regexOptions) For i As Integer = 0 To iBenchmarkIterations For Each _match As Match In _regexBenchmark.Matches(strTargetString) If _match.Success Then ' Do nothing End If Next If Benchmarking.CancellationPending Then e.Cancel = True Exit For End If Next e.Result = Date.Now.Subtract(startTime).TotalMilliseconds I'm not s

Regex Hero's Debut

So last week I launched regexhero.com and submitted it to a few social bookmarking sites (Dotnetkicks.com happened to be the most effective). Since then I've had 368 visits to the site. That's a pretty strong start for a brand new website. What Does The Tool Do? Regex Hero will dynamically highlight regular expression matches as you type. The whole idea behind it is to save as much time as possible and make it as convenient as possible to work with regular expressions. What's Special About It? It's the first online .NET regular expression tester with instantaneous highlighting that I know of. (Someone please correct me if I'm wrong.) Microsoft Silverlight lends itself to this functionality perfectly. I essentially wrote it and got it online in 3 days. Since then I've made some tweaks and minor improvements, but nevertheless it was extremely easy to build and I have to thank Microsoft and their development tools for that. The other thing I was sur