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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:03:08+00:00 2026-06-11T08:03:08+00:00

I am trying to find if a string exist in a word and extract

  • 0

I am trying to find if a string exist in a word and extract it. I have uses the instr() function but this works as the LIKE function: if part or the whole word exists it returns it.

Here I want to get the string ‘Services’ out, it works but if I change ‘Services’ to ‘Service’ it still works. I don’t want that. If ‘Service’ is entered it should return null and not ‘Services’

Modified:

What I am trying to do here is abbreviate certain parts of the company name.

This is what my database table looks like :

Word     | Abb
---------+-----  
Company  | com
Limited  | ltd
Service  | serv
Services | servs

Here is the code:

Declare 

    Cursor Words Is

    SELECT word,abb
    FROM abbWords


    processingWord VARCHAR2(50);
    abbreviatedName VARCHAR(120);
    fullName = 'A.D Company Services Limited';

BEGIN

    FOR eachWord IN Words LOOP


      --find the position of the word in name
       wordPosition := INSTR(fullName, eachWord.word);

       --extracts the word form the full name that matches the database
       processingWord := Substr(fullName,instr(fullName,eachWord.word), length(eachWord.word));

      --only process words that exist in name
      if wordPosition > 0 then
           abbreviatedName = replace(fullName, eachWord.word,eachWord.abb);
       end if;

    END lOOP;

END;

So if the user enters ‘Service’ I don’t want ‘Services’ to be returned. By this I mean word position should be 0 if the word ‘Service’ in not found instead of returning the position for the word ‘Services’

  • 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-11T08:03:10+00:00Added an answer on June 11, 2026 at 8:03 am

    Another alternative is to use something like:

    select replace(name,' serv ', ' Services ')
    from names;
    

    This will replace only the word ‘Serv’ situated between 2 spaces.

    Thank you,
    Alex.

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

Sidebar

Related Questions

I am trying to find a string in excel cells, and it works to
I am trying to find a sub-string in a string, but I am not
I'm trying to find aiport codes given a string like (JFK) or [FRA] using
i'm trying to find out if a string value EndsWith another string. This 'other
I'm trying to find all permutations of a string and sort them alphabetically. This
I'm trying to find a Delphi function that will split an input string into
I'm trying to find the type of file a path is. I have this
I'm trying to find and read a string from a text file using a
I am trying to find a way to reverse a string, I've seen alternatives
I'm trying to find a way to break a string at the second last

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.