title: Remove Optional() from Swift string using Regular Expressions
body: <p>I've a string having 'Optional(someVal)' in it. I want a regular expression to find and replace all occurrences of this keyword and replace just inside values in it. What I'm doing is...</p>
  
  <pre><code>query = "Insert Into table (Col, Col, Col, Col, Col, Col4, Col4, Col4, Col, AuditStatusId, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col ) Values ('71E3F86A059A40F0B3F7614E08ACD2B9', 1, Optional(4), Optional(6), ' ', '', Optional(40799), 'NULL', NULL, 1, 1, NULL, NULL, NUll, 0, NULL, 1, '', NULL , NULL, 90.0, 100.0, 70.0, 89.99, 0.0, 69.99, 1, 1, '2015-01-15 14:09:34 +0000', 0 )"
  </code></pre>
  
  <p>and replacing using regular expression,</p>
  
  <pre><code> query = query.stringByReplacingOccurrencesOfString("(\\Optional(w+))", withString: "$1", options: NSStringCompareOptions.RegularExpressionSearch, range: Range&lt;String.Index&gt; (start: query.startIndex, end: query.endIndex)) 
  </code></pre>
  
  <p>But this is not working even in Objective C. Anybody has idea how to do that??</p>
  
  <p><strong>EDIT:</strong>
  I've tried to overcome this by unwrapping values but it didn't come up with the solution what I'm looking for. What I need is to keep values as 'nil' in case no value and use value inside 'Optional(val)' in case value is entered. So please avoid suggesting Unwrapping for values. </p>