title: How can I have optional matches in a Perl regex?
body: <p>I have a string I read from a configuration file. Structure of the string is as follows;</p>
  
  <pre><code>(long_string)long_string(long_string)
  </code></pre>
  
  <p>Any item in brackets, including the brackets themselves, are optional. I have the following regular expression matching the whole string but I could not figure out how to make some parts of the regular expression optional with "?".</p>
  
  <p>Here are a few valid strings for input</p>
  
  <pre><code>(a)like(1)
  like(very long string here)
  like
  </code></pre>
  
  <p>Here is my regexp only matching the first one;</p>
  
  <pre><code>^\((?&lt;short&gt;.*)\)(?&lt;text&gt;.*)\((?&lt;return&gt;.*)\)$
  </code></pre>
  
  <p>How can I convert my regexp to make brackets optional for a match?</p>