Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6882183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:13:20+00:00 2026-05-27T05:13:20+00:00

I have a text that is a source-code file, I need to find the

  • 0

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.

lang('FOUND') and lang('FOUND',[loremipsum])

FOUND should be anything, is this value that I’m searching.

I will execute the Regexp in delphi, but I think regular expression is language independent

EDIT


Using the @Ken White answer and this Video I did this code, and works fine!

Regular expression: (?:lang\s*\(\s*')(.*?)(?:'\s*\)|'\s*\,\s*\[.*\]\s*\))

Include the Unit PerlRegEx on Uses

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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:13:21+00:00Added an answer on May 27, 2026 at 5:13 am

    (All of the code below was generated by Regex Buddy; I also used it to create the regex used. SubjectString is the content of your source file, loaded into a string; you can load the source file into a stringlist, for instance, and pass the Text.)

    Using TPerlRegex, available from the RegEx Buddy website, you can use

    var
      Regex: TPerlRegEx;
    begin
      ...
      Regex := TPerlRegEx.Create(nil);
      Regex.RegEx := 'lang\((.*)\)';
      Regex.Options := [preMultiLine];
      Regex.Subject := SubjectString;
      if Regex.Match then 
      begin
        repeat
          // matched text: Regex.MatchedExpression;
          // match start: Regex.MatchedExpressionOffset;
          // match length: Regex.MatchedExpressionLength;
          // backreference n text: Regex.SubExpressions[n];
          // backreference n start: Regex.SubExpressionOffsets[n];
          // backreference n length: Regex.SubExpressionLengths[n];
        until not Regex.MatchAgain;
      end;
    end;
    

    Using Delphi XE’s regex support (use Regex), you can use

    var
      Regex: TRegEx;
      MatchResults: TMatch;
    begin
        ...
      try
        Regex := TRegEx.Create('lang\((.*)\)', [roMultiLine]);
        MatchResults := Regex.Match(SubjectString);
        while MatchResults.Success do begin
          MatchResults := MatchResults.NextMatch();
        end;
      except
        on E: ERegularExpressionError do 
        begin
          // Syntax error in the regular expression
        end;
      end;
    end;
    

    In both cases, the text you want (the part between the parentheses) will be in capturing group 1 of each match.

    I seem to recall from other questions that you’re using Delphi 7, so the first will probably be the best option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, i'd to establish that i do have the text file in
I need to load some text (shader code) from a file that is placed
Currently I am doing this: I have text that looks like: Hello ${user.name}, this
I have Text file that contains data separated with a comma , . How
I have some text that is stored in a variable like this: <div class=foo>text
Suppose I have a text that I can easily parse. It consists of text
Hey, I have some text that is formatted like this: [quote]foo text[/quote] and I
I have a simple WPF (XAML) file that has some animated shapes and text.
i'm supposed to write code which when given a text file (source code) as
I have text that looks like: My name is (Richard) and I cannot do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.