Submatch display?

  • 2
  • Idea
  • Updated 7 years ago
  • Implemented
Hi,
I've come to depend on regex hero for one problem I work on almost constantly lately. I doubt it would have been possible for me to come as far as I have with your excellent little regex tester.
One feature I'd like to see is the display somewhere on the page of the submatches you get , in realtime, when you're trying to extract particular parts of a matched expression.
Would this be something you might be looking at implementing at some stage?
Photo of controlgeek

controlgeek

  • 4 Posts
  • 0 Reply Likes
  • thankful

Posted 7 years ago

  • 2
Photo of Steve Wortham

Steve Wortham, Official Rep

  • 136 Posts
  • 5 Reply Likes
Just to make sure I understand, are you basically wanting a list of the submatches?

For instance if the words, "dog" and "cat" were matched in a paragraph, then Regex Hero would display those matches in a listbox? Perhaps if you then select one of those matches in the listbox Regex Hero would automatically scroll to it. Let me know if I'm on the right track.
Photo of controlgeek

controlgeek

  • 4 Posts
  • 0 Reply Likes
Perhaps a terrible example might help.

Say you wanted to extract information from an xml file such as this:-

Tove
Jani
Reminder
Don't forget me this weekend!

If you made a regex like this:-
.+(.+).+(.+).+(.+).+(.+).+

regex hero could show you what results you had extracted in the submatch groups somewhere?

Yes, it's a lame regular expression but hopefully you get the idea :)
Photo of Steve Wortham

Steve Wortham, Official Rep

  • 136 Posts
  • 5 Reply Likes
Ah, I think I understand. So in this scenario you'd want to see:

Matches:
Tove
Jani
Reminder
Don't forget me this weekend!

Is that right? Another way to do that would be to use the replace feature like this:
http://regexhero.net/tester/?id=3946c...

But if I understand you correctly your suggestion would make this task a little easier. Another thing I could do while I'm at it is display the group names (if any) from each of these groups. I've seen other tools do this same thing. And while I don't typically use this feature myself, I could see how it might be useful.

Thanks for the suggestion. I'll get on it.
Photo of controlgeek

controlgeek

  • 4 Posts
  • 0 Reply Likes
That's exactly what I was meaning, but I should have thought of the replace feature as well. Thanks very much.
Photo of Steve Wortham

Steve Wortham, Official Rep

  • 136 Posts
  • 5 Reply Likes
You're very welcome. So I've just added this feature. I hope you like it...

http://regexhero.net/blog/2009/12/sho...
Photo of controlgeek

controlgeek

  • 4 Posts
  • 0 Reply Likes
Brilliant. That's exactly was I was after, and it's well integrated to the interface as well.
Well done.
Photo of Steve Wortham

Steve Wortham, Official Rep

  • 136 Posts
  • 5 Reply Likes
Excellent. And thanks again for the suggestion. Now that it's there I find myself using this feature more than I thought I would. It's pretty cool.