title: Regex a source code file
body: <p>I have a text that is a source-code file, I need to find the first parameter of all calls of this function. That can be called in this 2 ways. I'm completely dumb in regex.</p>
  
  <p><code>lang('FOUND')</code> and <code>lang('FOUND',[loremipsum])</code></p>
  
  <p>FOUND should be anything, is this value that I'm searching.</p>
  
  <p>I will execute the Regexp in delphi, but I think regular expression is language independent</p>
  
  <h2>EDIT</h2>
  
  <hr>
  
  <p>Using the @Ken White answer and this <a href="http://www.youtube.com/watch?v=DRR9fOXkfRE" rel="nofollow">Video</a> I did this code, and works fine!</p>
  
  <p>Regular expression: <code>(?:lang\s*\(\s*')(.*?)(?:'\s*\)|'\s*\,\s*\[.*\]\s*\))</code></p>
  
  <p>Include the Unit <a href="http://www.regular-expressions.info/download/TPerlRegEx.zip" rel="nofollow">PerlRegEx</a> on <code>Uses</code></p>
  
  <pre><code>procedure TForm1.Button1Click(Sender: TObject);
  var
    Regex: TPerlRegEx;
  begin
  
    Regex := TPerlRegEx.Create();
    Regex.RegEx := '(?:lang\s*\(\s*'')(.*?)(?:''\s*\)|''\s*,\s*\[.*\]\s*\))';
    Regex.Options := [preCaseless, preMultiLine];
    Regex.Subject := Memo1.Text;
    if Regex.Match then
    begin
      repeat
  
        Memo2.Lines.Add( Regex.Groups[1] );
  
      until not Regex.MatchAgain;
    end;
  
  end;
  </code></pre>