I don’t know about you, but writing a regular expression can sometimes be a lesson in patience when putting a pattern together to parse a log file or provide some sort of validation of input. Each time I need to write a RegEx pattern, I tend to find myself taking a string that I want to use as an example and then going to another ISE tab and begin working out the details of the pattern to ensure that it works like I want it to work. Given, this isn’t really that bad to do, but I wanted a way to show the results as I am working on the pattern so I can knock out what I am looking to do.

With that, I decided to write a UI using WPF (using XAML as the front end) that that would meet my requirements of having a place to input the string that I wanted to write a RegEx for and then another text box that would be used for my RegEx pattern. The next part is the DataGrid that would display the matches as I begin writing the pattern. Lastly, because I wanted to provide all of the options that are available when using RegEx for .Net, there is a pane at the very bottom that gives you all of the options like what you see below:

[System.Text.RegularExpressions.RegexOptions].GetEnumNames()

More information about these can be found at the following link: https://msdn.microsoft.com/en-us/library/yd1hzczs(v=vs.110).aspx

My main project for the RegEx Helper is here: https://github.com/proxb/RegExHelper. This UI only has a single tab which is used for checking a string to find a match.

This does run as a function, so you will need to dot source the script file to load the function into the console.

. .\Invoke-RegExHelper.ps1 Invoke-RegExHelper

I do have a Dev branch that has a version of this project that includes another tab that allows you to put a log file in (or part of a log) so you can write a pattern that can parse out a specific item or items and will highlight the results when you click on the Hightlight button. I haven’t made this part of the Master branch as I want to solve the performance issues when the size of the log is large and the number of matches being highlighted are fairly large as well. This is where I hope to have some community participation to help iron out this issue to really make this a great tool. The link to that branch is here: https://github.com/proxb/RegExHelper/tree/Dev

Anyways, I hope that you find this useful and if you want to help contribute to it, then you know what to do! Fork the repo and do a Pull Request of course!

I plan to write a follow up post on just how I built this and my thought process on the design, but today I just wanted to get it out in the open and start gathering feedback on this tool.