title: JavaScript Regex Pattern that contains parentheses
body: <p>Using JavaScript I need to check a string for the first instance of a given pattern and return everything after, and including, the pattern. See example below for a typical string, pattern and desired result.</p>
  
  <p>The main problem I am having is that the pattern will almost certainly contain special characters such as parentheses. I cannot alter the pattern manually to escape those special characters. Unless I am able to do that using <code>replace</code> first?</p>
  
  <p>e.g. <code>result = string.match(pattern.replace</code>(special with escaped))</p>
  
  <p>I'm not sure if anything like that is even possible. Regex always gives me a headache and I would appreciate any pointers in the right, or alternative, direction.</p>
  
  <p><strong>Background</strong></p>
  
  <p>I am trying to do some complex mixins for LESS. So I am restricted to single line JavaScript by escaping with the back-tick. See <a href="http://lesscss.org/#-javascript-evaluation" rel="nofollow noreferrer">here</a> for information regarding using JavaSCript in LESS. I was hoping to use the new variadic argument support to get multiple color-stops. e.g. .<code>radial-gradient(@shape, @position, @colorStops...)</code> However LESS only gives you the full range of arguments passed when you use @arguments. So I am hoping to use regex to use @arguments for the string and @colorStop for the pattern and return everything after, and including, the first color-stop. LESS returns the first color-stop variable when using @colorStop. The general concept was taken from <a href="http://www.toekneestuck.com/blog/2012/05/15/less-css-arguments-variable/" rel="nofollow noreferrer">here</a>)</p>
  
  <p><strong>For Example:</strong></p>
  
  <blockquote>
    <p>String: circle 0% 50% rgba(96, 16, 48, 0) 9px #661133 10px rgba(96,
    16, 48, 0) 11px</p>
    
    <p>Pattern: rgba(96, 16, 48, 0) 9px</p>
    
    <p>Result: rgba(96, 16, 48, 0) 9px #661133 10px rgba(96, 16, 48, 0) 11px</p>
  </blockquote>