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 4014788
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:32:21+00:00 2026-05-20T09:32:21+00:00

I have a string, lets call it MyStr . I am trying to get

  • 0

I have a string, lets call it MyStr. I am trying to get rid of every non-alphabetical character in the string. Like, in IM’s like MSN and Skype, people put their display names like [-Bobby-]. I would like to remove everything in that string that is not an alphabetical character, so all I am left with, is the “name”.

How can I do that in Delphi? I was thinking about creating a TStringlist and store each valid character in there, and then use IndexOf to check if the char is valid, but I was hoping for an easier way.

  • 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-20T09:32:22+00:00Added an answer on May 20, 2026 at 9:32 am

    The simplest approach is

    function GetAlphaSubstr(const Str: string): string;
    const
      ALPHA_CHARS = ['a'..'z', 'A'..'Z'];
    var
      ActualLength: integer;
      i: Integer;
    begin
      SetLength(result, length(Str));
      ActualLength := 0;
      for i := 1 to length(Str) do
        if Str[i] in ALPHA_CHARS then
        begin
          inc(ActualLength);
          result[ActualLength] := Str[i];
        end;
      SetLength(Result, ActualLength);
    end;
    

    but this will only consider English letters as “alphabetical characters”. It will not even consider the extremely important Swedish letters Å, Ä, and Ö as “alphabetical characters”!

    Slightly more sophisticated is

    function GetAlphaSubstr2(const Str: string): string;
    var
      ActualLength: integer;
      i: Integer;
    begin
      SetLength(result, length(Str));
      ActualLength := 0;
      for i := 1 to length(Str) do
        if Character.IsLetter(Str[i]) then
        begin
          inc(ActualLength);
          result[ActualLength] := Str[i];
        end;
      SetLength(Result, ActualLength);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have an array like this: string [] Filelist = ... I
I have a big string (let's call it a CSV file, though it isn't
Lets say I have a string COLIN. The numeric value of this string would
How do you split a string? Lets say i have a string dog, cat,
I have a method lets say: private static String drawCellValue( int maxCellLength, String cellValue,
Lets say I have the following code: abstract class Animal case class Dog(name:String) extends
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
Let's say I have a class: class Foo { public string Bar { get
I have two tables that I want to fetch data from. Lets call them
Situation: c#, sql 2000 I have a table, lets call it 'mytable' with 30

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.