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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:39:07+00:00 2026-05-28T02:39:07+00:00

For example, I have this string This is a trial string, and I know

  • 0

For example, I have this string “This is a trial string”, and I know that I want the word which is at position 2 (in this case, the word “This”). The letter at index 2 of the whole string is part of the word “This”, so I want to get that word. In case I supply the index of a separator, then I wouldn´t get any specific word, just the separator.

How can do this? I found this link, but it shows how to get everything AFTER a certain index, I need the word AT a certain index.

  • 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-28T02:39:08+00:00Added an answer on May 28, 2026 at 2:39 am

    You could make an extension method that checks for spaces:

    Call like this: string theWord = myString.GetWordAtPosition(18);

        static class WordFinder
        {
            public static string GetWordAtPosition(this string text, int position)
            {
                if (text.Length - 1 < position || text[position] == ' ') return null;
    
                int start = position;
                int end = position;
                while (text[start] != ' ' && start > 0) start--;
                while (text[end] != ' ' && end < text.Length - 1) end++;
    
                return text.Substring(start == 0 ? 0 : start + 1, end - start - 1);
    
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this HTML string which often has a lot of whitespaces Example: <p>All
for example we have this string: hello_my name_is_bob and want to get only the
I have a string as const char *str = Hello, this is an example
I have this very simple example that I am using to learn structs in
For example I have this string of 2 json objects: {"glossary": {"title": "example glossary"},
I have a comma-separated string that I want to convert into an array, so
I have this statement: String cap = Regex.Replace(winCaption, @[^\w\.@-], ); that transforms Hello |
I have this String: foo bar 567 baz Now I want to add before
I have this string AnyText: jonathon <usernameredacted@example.com> Desired Output Using Regex AnyText: <usernameredacted@example.com> Omit
I have this example code: string query = select * from xy where id

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.