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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:25:14+00:00 2026-06-01T16:25:14+00:00

How do I get the nth word in a sentence or a set of

  • 0

How do I get the nth word in a sentence or a set of strings with space delimiter?

Sorry for the change in the requirement.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-06-01T16:25:15+00:00Added an answer on June 1, 2026 at 4:25 pm

    By using instr.

    select substr(help, 1, instr(help,' ') - 1)
      from ( select 'hello my name is...' as help
               from dual )
    

    instr(help,' ') returns the positional index of the first occurrence of the second argument in the first, inclusive of the string you’re searching for. i.e. the first occurrence of ' ' in the string 'hello my name is...' plus the space.

    substr(help, 1, instr(help,' ') - 1) then takes the input string from the first character to the index indicated in instr(.... I then remove one so that the space isn’t included..


    For the nth occurrence just change this slightly:

    instr(help,' ',1,n) is the nth occurrence of ' ' from the first character. You then need to find the positional index of the next index instr(help,' ',1,n + 1), lastly work out the difference between them so you know how far to go in your substr(.... As you’re looking for the nth, when n is 1 this breaks down and you have to deal with it, like so:

    select substr( help
                 , decode( n
                         , 1, 1
                         , instr(help, ' ', 1, n - 1) + 1
                           )
                 , decode( &1
                         , 1, instr(help, ' ', 1, n ) - 1
                         , instr(help, ' ', 1, n) - instr(help, ' ', 1, n - 1) - 1
                           )
                   )
      from ( select 'hello my name is...' as help
               from dual )
    

    This will also break down at n. As you can see this is getting ridiculous so you might want to consider using regular expressions

    select regexp_substr(help, '[^[:space:]]+', 1, n )
      from ( select 'hello my name is...' as help
               from dual )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Bash, I want to get the Nth word of a string hold by
How can I get the Nth row using Linq? both columns are text so
Is it possible to get the 'nth' return value from a function without having
I hope to find a way to get the value in the Nth column
parentId=$(this).closest('tr').find('td:nth(6)')[0].textContent; I am trying to get ID from flexigrid column. It works fine in
Unless it's not supposed to but I can't seem to get nth-child to acknowledge
Suppose I have this range: (aaaaa..zzzzz) How would I get the Nth item from
What's the best SQL query in SQLite to get the Nth item from a
How can i get the nth row position from table without using limit ?
Is there any bash command that will let you get the nth line of

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.