Problem with Javascript RegExp-mask
        Posted  
        
            by OrjanL
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by OrjanL
        
        
        
        Published on 2010-04-02T07:20:24Z
        Indexed on 
            2010/04/02
            7:23 UTC
        
        
        Read the original article
        Hit count: 414
        
JavaScript
|regex
I have a string that looks something like this:
{theField} > YEAR (today, -3) || {theField}  < YEAR (today, +3)
I want it to be replaced into:
{theField} > " + YEAR (today, -3) + " || {theField}  < " + YEAR (today, +3) + "
I have tried this:
String.replace(/(.*)(YEAR|MONTH|WEEK|DAY+)(.*[)]+)/g, "$1 \" + $2 $3 + \"")
But that gives me:
{theField} > YEAR (today, +3) || {theField}  >  " + YEAR  (today, +3) + "
Does anyone have any ideas?
© Stack Overflow or respective owner