# Processing regular expressions?

**URL:** <https://www.ruby-forum.com/t/processing-regular-expressions/197526>\
**Category:** Ruby\
**Created:** [October 15, 2010, 5:06pm UTC](https://www.ruby-forum.com/t/processing-regular-expressions/197526 "2010-10-15T17:06:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [October 15, 2010, 5:06pm UTC](https://www.ruby-forum.com/t/processing-regular-expressions/197526/1 "2010-10-15T17:06:09Z")

</div>

I’m interested in manipulating & munging regular expressions, not the  
matches, but the regexes themselves.

Specifically, I want to parse out the groups/captures in a regex much  
like .named\_captures and .names, but for ALL captures, not just the  
named ones.

My end goal is to take a regex like /(one)(two)(three)four/ and split it  
up into three separate regexs  
/(one)twothreefour/  
/one(two)threefour/  
/onetwo(three)four/

Any pointers would be appreciated.

- Jasen.

---

<div class="post-metadata">

**Author:** ![jasen\_j](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c6cbf5/32.png) [@jasen\_j](https://www.ruby-forum.com/u/jasen_j)\
**Post date:** [October 15, 2010, 8:15pm UTC](https://www.ruby-forum.com/t/processing-regular-expressions/197526/2 "2010-10-15T20:15:11Z")

</div>

I haven’t found anything like that yet. Would love to hear about any  
such tools.

I recently did a couple of experiments that might be of interest of  
you. It is basically a preprocessor that expands repetitions and adds  
“aliases”. The code and a brief description are at:

> **[GitHub - ammar/meta\_re: An experimental regular expression "preprocessor"](https://github.com/ammar/meta_re)**
>
> An experimental regular expression "preprocessor". Contribute to ammar/meta\_re development by creating an account on GitHub.

Based on those experiments and some valuable feedback and ideas I  
received from others, I started work on a standalone regular  
expression parser. It is still in an very early stage, but might be of  
interest to you as well. That project repo is at:

> **[GitHub - ammar/regexp\_parser: A regular expression parser library for Ruby](https://github.com/ammar/regexp_parser)**
>
> A regular expression parser library for Ruby. Contribute to ammar/regexp\_parser development by creating an account on GitHub.

I would be interested in any comments you might have about either.

Regards,  
Ammar

---

<div class="post-metadata">

**Author:** ![jasen\_j](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c6cbf5/32.png) [@jasen\_j](https://www.ruby-forum.com/u/jasen_j)\
**Post date:** [October 15, 2010, 10:39pm UTC](https://www.ruby-forum.com/t/processing-regular-expressions/197526/3 "2010-10-15T22:39:45Z")

</div>

On Fri, Oct 15, 2010 at 6:07 PM, Jasen J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> /one(two)threefour/  
> /onetwo(three)four/
> 
> Any pointers would be appreciated.
> 
> - Jasen.

I haven’t found anything like that yet. Would love to hear about any  
such tools.

I recently did a couple of experiments that might be of interest of  
you. It is basically a preprocessor that expands repetitions and adds  
“aliases”. The code and a brief description are at:

> **[GitHub - ammar/meta\_re: An experimental regular expression "preprocessor"](https://github.com/ammar/meta_re)**
>
> An experimental regular expression "preprocessor". Contribute to ammar/meta\_re development by creating an account on GitHub.

Based on those experiments and some valuable feedback and ideas I  
received from others, I started work on a standalone regular  
expression parser. It is still in an very early stage, but might be of  
interest to you as well. That project repo is at:

> **[GitHub - ammar/regexp\_parser: A regular expression parser library for Ruby](https://github.com/ammar/regexp_parser)**
>
> A regular expression parser library for Ruby. Contribute to ammar/regexp\_parser development by creating an account on GitHub.

I would be interested in any comments you might have about either.

Regards,  
Ammar
