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

  • SEARCH
  • Home
  • 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 3284462
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:09:26+00:00 2026-05-17T20:09:26+00:00

In php and java there are explode and tokenizer function to convert a string

  • 0

In php and java there are explode and tokenizer function to convert a string into array without punctuations. Are are functions or some way in delphi to do the work. Suppose there is a large file ” This is, a large file with punctuations,, and spaces and numbers 123…” How can we get
array “This is a large file with punctuations and spaces and numbers 123”

Thank you very much in advance.

Yes, we want only [0..9],[a..z],[A..Z], like \w in regex. Can we use regex in Tperlregex to extract \w and put them in Tstringlist as if tstringlist is a array, but it may not be so efficient? Thank you.

  • 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-17T20:09:26+00:00Added an answer on May 17, 2026 at 8:09 pm

    If you need a function that takes a string and returns an array of strings, these strings being the substrings of the original separated by punctuation, as Eugene suggested in my previous answer, then you can do

    type
      StringArray = array of string;
      IntegerArray = array of integer;
      TCharSet = set of char;
    
    function split(const str: string; const delims: TCharSet): StringArray;
    var
      SepPos: IntegerArray;
      i: Integer;
    begin
      SetLength(SepPos, 1);
      SepPos[0] := 0;
      for i := 1 to length(str) do
        if str[i] in delims then
        begin
          SetLength(SepPos, length(SepPos) + 1);
          SepPos[high(SepPos)] := i;
        end;
      SetLength(SepPos, length(SepPos) + 1);
      SepPos[high(SepPos)] := length(str) + 1;
      SetLength(result, high(SepPos));
      for i := 0 to high(SepPos) -  1 do
        result[i] := Trim(Copy(str, SepPos[i] + 1, SepPos[i+1] - SepPos[i] - 1));
    end;
    

    Example:

    const
      PUNCT = ['.', ',', ':', ';', '-', '!', '?'];
    
    procedure TForm4.FormCreate(Sender: TObject);
    var
      str: string;
    begin
      for str in split('this, is, a! test!', PUNCT) do
        ListBox1.Items.Add(str)
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there a Java version of the PHP function checkdnsrr ?
Is there some way of using magic methods in Java like there is in
is there a possible bit of code (php, java, css, html) that will force
Coming from PHP with some Java Struts 2.0 experience any tips/tricks on learning GWT?
Possible Duplicate: Is there garbage collection in PHP? In java there is a concept
There is Java tool (it is called Mallet) http://mallet.cs.umass.edu/download.php which I want to use
There is a Java service that I need to invoke from PHP that looks
I'm in the process of moving an application from PHP to Java and there
Possible Duplicate: Parsing query strings in Java PHP has parse_str() , is there an
I am primarily a Java and PHP developer and have some experience with .NET

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.