In the past I commented on Regular Expression utilities here. Today I came across another one that I really like called Regulator that appears on GDN. Unfortunately, the source code is not yet posted publicly but presumably that will happen with time. Until then I also presume you can join the workspace to gain access.
While taking a look at it I finally figure out that the reason Regex.Split() exists is because it is especially difficult (meaning I don't know how) to parse expressions that begin with the same pattern but don't have any meaningful ending pattern especially when they cross the line boundary. In my case I was trying to split the following string:
<<What is your name <enter name>?: >>Inigo Montoya <The person's name> <<Your name is "Inigo Montoya."
In my case I wanted to split the input into each string following "<<" and ">>" and allowing a match to span a line. Doing this using Regex.Match() is beyond my capabilities but Regex.Split() with a regular expression of "(>>|<<)" was relatively easy. It is more cumbersome to retrieve the exact value you want as I don't believe they can be named but still, I was able to get this to work.
P.S. I am trying to parse the above text for an NUnitConsole program I am in the process of writing. The program is designed to provide a unit testing tool for command line programs. To begin this will be callable from NUnit but in the not too distant future I hope to make it a command line tool as well.
7:18:02 AM
|