Replace the last occurrence of a word in a string

Hello

I need to replace the last occurrence of a word in the string. Example of form:

"I like fruits and vegetables as" need to replace the last occurrence of 'like' that is just before the vegetables and not 'as' before the fruit.

Something like that!

SELECT
    REGEXP_REPLACE('I like fruits and also like vegetables','like','hate',1,2) data_col
FROM dual;

Tags: Database

Similar Questions

  • Search for the last occurrence of a substring

    How to search for the last occurrence of a substring in a string? In more detail: I have the array with the names of files, and I want to split the file name extension in a separate column. The name extension doesn't have a fixed rate with (can be 'c', "" jpg"or"mpeg", etc.), and names of files themselves can contain points (if this is possible:"recording.of.last.meeting.mpeg".)

    So the only way to extract the name extension is to look for the last appearance of a dowry and split on everything after the last point. How can I do this? I worked with a sybase database before and there was a string function to search for the right of the string. Is there something similar in Oracle?

    If you're on 10g, you can

    with t
    as
    (
    select 'recording.of.last.meeting.mpeg' file_name from dual
    )
    select regexp_replace(file_name,'^.+\.') fiel_extension
      from t
    
  • What has replaced the last good configuration in windows 8

    Hello

    I hear 2 weeks there is a member of the microsoft community this last good configuration does not exist anymore in windows safe mode 8.

    is this true? If Yes, what feature has replaced the last good configuration?

    Thank you

    Joha

    You can access all the options of recovery like this:

    1. Click the Power Options icon, and then hold down the SHIFT key while you click the Restart option. Keep now shift until the screen shows it restarts.
    2. On the first screen that appears, select troubleshooting, and then select Advanced Options. Finally, choose the boot settings and click Restart.
    3. On the next screen, you will see things like Safe Mode and service options which would be "last well known."
  • Replace the last comma by "and".

    Hi all

    Please let me know is there a simple way to replace the last comma in as string with 'and '.

    for example: 1. abc, xyz, wuv must be returned to abc, xyz and wuv

    2 abc, wuv must be returned, abc and wuv

    3 abc and pqr, cuq, wuv must be returned to abc and pqr, cuq wuv

    DB version: 11.2.0.3

    Thank you

    DS

    Hello

    Here; s in one direction:

    REGEXP_REPLACE (str

    , ',([^,]*)$'

    , 'and \1 '.

    )

  • How can I add a style "BOLD" grep on the first occurrence of a Word?

    Hi all

    I need help on adding a style "BOLD" grep on the first occurrence of a Word.

    I can add the "BOLD" to the word, but it adds to all occurrences, see below:

    GREP style (Incorrect)

    Apply Style: "BOLD"

    Text: \ < Lorem Ipsum\ >

    Nam Lorem Ipsum semper pellentesque tincidunt. UT nisi sit amet arcu nulla tristique dictum. SED commodo total non mauris cursus pretium. Lorem Ipsum Aliquam erat volutpat. Morbi id pretium justo. Nam lorem quis facilisis molestie risus fermentum. Vestibule ut sem elit. Nunc eget neque Sed elementum augue EU outbound.

    I need only the "BOLD" to add to the first occurrence of the word, as below:

    Nam Lorem Ipsum semper pellentesque tincidunt. UT nisi sit amet arcu nulla tristique dictum. SED commodo total non mauris cursus pretium. Lorem Ipsum Aliquam erat volutpat. Morbi id pretium justo. Nam lorem quis facilisis molestie risus fermentum. Vestibule ut sem elit. Nunc eget neque Sed elementum augue EU outbound.


    Thanks in advance for the help!

    This should do it for you

    Apply style

    "BOLD"

    text (? i) ^(.+?) Lorem Ipsum

    apply the stye

    Book

    text: ^. * ? (? = Lorem Ipsum)

    The first expression search all the text from the beginning of the parapgrah through the Lorem Ipsum

    The other defines the rest of the text before the Lorem Ipsum to the base style (book, novel, or whatever your basic style)

  • Find the first occurrence of a Word

    I have a script which detects and counts all occurrences of a Word.

    I need the script to find the FIRST occurrence of a Word only.

    Can any advise please how do I change the script to find the first occurrence of the word?

    Script as follows:

    {

    numWords = this.getPageNumWords var (0);

    for (var i = 0; i < numWords; i ++)

    {

    var ckWord = this.getPageNthWord(0,i);

    If (ckWord is 'MATERIAL')

    {

    / * Script going here based on the finds the first occurrence of the word 'MATTER ' * /.

    }

    }

    }

    I tried var CKWord = this.getPageNthWord (0,0); but reports from the rear console is UNDEFINED?

    numWords = this.getPageNumWords var (0);

    var number = 0;

    for (var i = 0; i)
    var ckWord = this.getPageNthWord(0,i);
    If (ckWord == "ISSUED") {}
    Count ++;
    If (count == 2) {}
    var = this.mouseX Coord.

    var annot = this.addAnnot({)
    page: 0.
    type: "Stamp."
    name: "AppStamp."
    Rect: [coord + 1000, 2300, 30, 2820]
    rotation: 90,.
    ({AP: '#C94cHAFFa42U1gTH5Tug5C'});
               
    break;
    / * this.flattenPages (); */
    }
    }
    }

  • How to replace the first occurrence of a substring

    How to replace the first occurrence of a substring of my original string? everything built in features in PL/SL?
    EX: Original string: "webinweb" I need the output of string as: "xyzinweb" simply replace occuarnce first of 'web' by "xyz".
    SQL> select   regexp_replace('webinweb','web','xyz',1,1) from dual
    /
    REGEXP_R
    --------
    xyzinweb
    
  • Replace the last dialed number

    Is it possible to always overthrow the composition of the last number with a different contact number? By doing so, I would like to achieve that by hitting the button Redial (also in my Kia car) I'll always dial my wife.
    Thank you.
    David

    Create a background application
    http://supportforums.BlackBerry.com/T5/Java-development/create-a-background-application/Ta-p/445226

    You can save a http://www.blackberry.com/developers/docs/7.1.0api/net/rim/blackberry/api/phone/phonelogs/PhoneLogLi... that is called whenever the call log is changed.
    You can then replace the number (and perhaps store, so when you replace the next number, you can restore the old one?)

  • Add the signature field to the second occurrence of two words (nieme Word) on the page


    I have a script that searches for two words ("APP ENG") on a page and adds a digital signature field.

    The trick is that there are two occurrences of these words and place the script in the field of digital signature on the first ocurrance of the two words.


    I need the digital signature script to add to the second occurrence of these two words.

    There was a counter added the script, but this place then the field on the word ("ENG"), it might have to do with the meter to count one word instead of two.


    If someone can help me to modify the script to count the words and the occurrences of two words instead of one word it would be most appreciated.

    Script as follows:


    var ckWords; pair of words to test

    var number = 0;

    numWords = this.getPageNumWords (0); number of words on the page

    loop through the words on the page

    for (var j = 0; j < numWords-1; j ++) {}

    get the pair of words to test

    ckWords = this.getPageNthWord (0, j) + ' ' + this.getPageNthWord (0, j + 1); test words

    If (ckWords == "ENG APP") {}

    Count += 1;

    If (count == 2) {}

    var q = this.getPageNthWordQuads (0, j);

    convert quads in the rotation by default user space

    Userspace used by links

    m = (new Matrix2D).fromRotated(this,0);

    mInv = m.invert)

    r = mInv.transform (q)

    r = r.ToString)

    r = r.split(",");

    var m = this.addField ("EngSignature", "signature", 0,

    ([r [0], [1] r, r [2], r [5]]) ;

    }

    }

    }

    Thank you.

    You must use the left coordinates of the first table and the right of the second table.

  • Grep for styling the second occurrence of a Word

    Hi all

    I'm putting a dictionary for children.

    name of the bicycle

    a vehicle with two wheels in tandem, usually propelled by pedals attached to the rear wheel by a chain and have the handlebars for steering and a saddlelike seat. • Some find it faster to ride a bicycle and weaving through cars to take the bus or drive a private car.

    I managed to match the first occurrence of the bicycle to the second (underlined below) using the following grep.

    (?:^( \w+).+\r.+(\r.+)?) (\1)

    bike noun

    a vehicle with two wheels in tandem, usually propelled by pedals attached to the rear wheel by a chain and having the steering handlebars and a seat saddlelike. • some found it quicker to mount a bike and weaving through cars to take the bus or drive a private vehicle.

    This grep (that which) works as expected in the dictionary, but now I need to be able to select only the second word (in italics and in red in the example above) to be able to give him the correct character style.

    Any help would be greatly appreciated.

    Thanks in advance.

    Stephen

    GOAL!

  • Zone alarm (free) to always safe? It keeps failing and you want to replace the last version.

    Were do the windows that open to Zone Alarm telling me to replace the version I have.

    In the end I did, and he could not recognize it's own updates or let me turn on the antivirus.

    I then uninstalled from the PC and went to their website and download the latest version.

    within 30 minutes of the hotel, it's throw up the same window asking me to replace it with the latest version. The attached picture is what I get with this latest version. I'm about to go through it all on my laptop too, I should ignore the adds to update?.

    Thank you all, I'll just stay clear of Zone Alarm in the future.

    I liked the presentation how functional it is firewall worked, especially in what concerns the software installed, but now is too much of a risk, and there are others out there.

    I am happy with Avast AV and FW of Comodo.

    Avast and defender widows say there is not two viruses the Zone Alarm they said was there.

    You can consider this thread concluded, as I don't see point to continue with Z / a time, there was a power outage and others are just as free.

  • Locate and replace the last paragraph style

    With .js or grep, I want to change the style of the last paragraph ball against one with more space after, there are a lot of them in one story mixed with other styles.

    Change this:

    • B. blarrblarr (bullet style)
    • B. b. b. b. (bullet style)
    • B. b. change it (bullet style)

    To do this:

    • B. blarrblarr (bullet style)
    • B. b. b. b. (bullet style)
    • B. b. change this (last bullet style)

    Is this possible? If anyone can help would be great!

    Thank you very much!

    I think that this JavaScript does the job. You may need to change the style names to match yours. In addition, it assumes that the styles are not grouped in a folder.

    //DESCRIPTION: Fix last bullet paragraphs
    
    (function() {
         if (app.documents.length > 0) {
              findFixLastBullets(app.documents[0]);
         }
         function findFixLastBullets(aDoc) {
              setupFindText();
              app.findTextPreferences.appliedParagraphStyle =  "Bullet";
              var myFinds = aDoc.findText();
              for (var j = myFinds.length - 1; j >= 0; j--) {
                  var lastPara = myFinds[j].paragraphs[-1];
                  // if next para already BulletLast do nothing
                  var nextPara = lastPara.insertionPoints[-1].paragraphs[0];
                  if (nextPara.appliedParagraphStyle.name == "BulletLast") continue;
                  lastPara.appliedParagraphStyle = "BulletLast";
              }
         }
         function setupFindText(find, change, wholeWd, caseSense, foots, hidLayers, lockedLayers, lockedStories, masters) {
         app.findTextPreferences = null;
         app.changeTextPreferences = null;
         try { app.findTextPreferences.findWhat = find } catch(e) {};
         try {app.changeTextPreferences.changeTo = change } catch(e) {};
         app.findChangeTextOptions.properties = {
              caseSensitive:(caseSense == null ? false : caseSense),
              wholeWord:(wholeWd == null ? false : wholeWd),
              includeFootnotes:(foots == null ? false : foots),
              includeHiddenLayers:(hidLayers == null ? false : hidLayers),
              includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
              includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
              includeMasterPages:(masters == null ? false : masters)
         }
    } // end setupFindText
    
    }())
    

    Note the small touch that if the next paragraph is already BulletLast, it ignores who found the text. This allows you to run the script more than once if you add more text.

    Dave

  • Remove the last Chr (13) &amp; Chr (10) of a string

    Hello, all.

    I am trying to get confirmation of the files to download on Amazon for its program "Charge when ship".  I have the file create as it should with one minor exception.

    I'm creating a variable, giving him the information header column and that finishing by Chr (13) & Chr (10); I'm a loop in a query to add information, each iteration bugs Chr (13) & Chr (10) at the end of it; I'm taking this variable and writing data to a file using CFFILE.

    But I think that the last Chr (13) & Chr (10) is that servers Amazon think there is a line of information that it really is, and it's one mistake.

    Can someone tell me how to remove the last Chr (13) & Chr (10) of the variable before writing this file?

    Thank you

    ^_^

    What gives the information header column and that finishing by Chr (13) & Chr (10); I'm a loop in a query to add information, each iteration bugs Chr (13) & Chr (10) at the end of it; I'm taking this variable and writing data to a file using CFFILE.

    Trim() the variable or modify the code, so it does not generate an extra newline.

    Because your content has a header, place the new line at the beginning of each iteration of the query characters.

    #headerColumnsHere #.

    #chr (13) ##chr (10) # #ColumnA # ColumnB #... etc...

  • To combine files to PDF, a file has been replaced by another, the program automatically replaces the files? in other words, I did not choose, and it was merged into the document.

    When you combine files to PDF a single file has been replaced by another, can the program automatically replace files? in other words, I has not been chosen, and it has been merged in the document.

    Sorry, I don't have any ideas. This isn't a usual problem. It may be useful to repeat carefully to see if it happens again and check that the files contain what you expect.

  • I lost documents and settings since the last update, and now Word doesn't

    When I load Word now all I get is a dialog box indicating that the information is on the installation disc, but it's not. It is for me the propt, "the feature you are trying to use is on a CD-ROM that is not available.

    Insert the ' Microsoft Office 2000 Proffesional disc and click OK.
    I did and then all I get is "fatal error during installation and it crashes."
    This happens only for an automatic update of Vista in early March, and now I can't wWord to work because I think it cannot find Documents and Settings, which seems to have been deleted in the update.
    What I'm doing. I tried to reload the office and it still does not work.
    Help

    Documents and settings are still there, I can tell because you can log in.

    Uninstall, and then reinstall Office.

    PS, Documents and Settings is a Windows XP name. 'S called it users in Vista and later versions.

Maybe you are looking for