Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • But when I run this (via regex101.com), it matches the entire string. What I'm trying to do in Ruby is to match the first pattern and second pattern and strip those out, leaving what is left behind. What I'm looking for is "match this pattern AND this pattern". Is this possible? Commented Dec 2, 2016 at 18:53
  • The required groupings (the things inside the ()) are already there. Refer here to learn how to access grouped sub-expression matches. Otherwise just use the special match variables $1.. $n to access those (More on this here). Note that these special match variables work in almost any language that supports regex matching. Commented Dec 2, 2016 at 18:59