Replace in the last instance of expression string research with new words

I have the T table with the data in the example below. The data have occurrences of phrace "ab" several times, several places. I want to replace the LAST occurrence of "ab" with the value "ab_last". How to write this query?
with T as
(
select 'some symbols
  ab cd
  lot of occurences of ab here
  this is last ab occurence: ab
  some more symbols ' s from dual
)   
select REGEXP_REPLACE(T.s, '([^ab.]+)','\1_last;') as s from T
/*
END some sym_last;bols
  ab cd
  lot of occurences of ab here
  this is last ab occurence: ab
  some more symbols 
*/
I think that Oracle has no function "ReplaceLast". And regular expressions cannot specify filter "the last of ' as I understand it. Then how to write the query?

Expected result:
'some symbols
  ab cd
  lot of occurences of ab here
  this is last ab occurence: ab_last
  some more symbols '
--
I have the 10g version.
regexp_replace(T.s,'ab','ab_last',instr(T.s,'ab',1,-1))

Tags: Database

Similar Questions

  • How to identify the last instance of a dynamic table row

    Hi all

    I'm trying to figure out how to create an action for my form in Livecycle Designer ES2, which will affect the last instance of a dynamic table row. I have a table with a repeatable row where the user will enter information about a part purchased and I have buttons that allow the user to add and remove the lines. I need to create a line extra addition button which will add a new instance of the repeatable table line (this is not a problem) and disable and change the background color of the first cell in the row added. The problem I have is how to have an action that affects the last instance of a line.

    If anyone knows how to do this in Javascript, I would appreciate some advice/help.

    Hello

    I think that it is beyond providing an action. You will have a need to write JavaScript directly.  When you call the addInstance method it returns the new line, if you can do something like;

    var line = Table1._Row1.addInstance ();

    line. TextField1.border.fill.color.value = "255,0,0";

    line. TextField1.access = 'protected ';

    To find the last line and do the same thing, you can do something like;

    var line = Table1.resolveNode ("Row1 [" + (Table1._Row1.count - 1) + "" "]" ");

    line. TextField1.border.fill.color.value = "255,0,0";

    line. TextField1.access = 'protected ';

    Concerning

    Bruce

  • Check the last instance of a textfield is not null

    I have a repeating subform that includes a textfield for the user to enter his name. When the user clicks a button e-mail customized to send the form, I first want to check if the last instance of this field is filled (non-null). I don't care about previous instances only the last instance. Custom e-mail button is pushed down below each instance of the subform is always just below the last instance of the repeating subform. Is it possible to refer to the last instance of a field in the subform when I do not know how many instances are created?

    Thank you

    Hi DKinsley,

    I think that the code and the following steps will solve your problem.

    (1) in order to know the last instance, you must find the number of available instances. This can be achieved with the following code.

    var totalRowInstances = xfa.resolveNode ("form. Name.txtName").instanceManager.count;

    (2) to access the last value of the index,

    lastIndex var = totalRowInstances-1;

    [Since the index always starts with 0]

    var lastIndexNameCheck = xfa.resolveNode ("form. ("Name [" + lastIndex + '] '). txtName.rawValue;

    If (lastIndexNameCheck! = null)
    {
    do something
    }
    on the other
    {
    do something
    }

    Please Note: here, form - refers to the root node, name - refers to the subform, txtName - made reference in the name of a text field.

    Please let me know if this helped.

    Thank you
    VJ

  • How to hide all instances of subform (via a click event of the button) except the last instance.

    When my form is rendered, it can contain multiple 'case' of a subform full page.  So basically, I have a subform labeled "Info" that spans a full page. Depending on how the form is used when a new instance is added to the document it essentially new creates an entire page.

    What I'm trying to hide all instances of subform ("Info"), except the LAST instance that is always on the last page.

    Theoretically, by hiding all previous subform instances (for example, 1-4) and keep only the last instance, it will reduce the number of pages 5-to-1.

    Hope it makes sense.

    SO I guess I need a way to get the number of instances of complete subform, then hide all instances, but the last instance (via a button click).

    Thanks in advance for your help.

    I belive I've thought about it.

  • Looking for the last element of a string defined in a specific character style

    I should find each space which is the last character of a string in a particular character style. For example, in the "123 456 789" passage (the underlined part here indicating a passage located in a specific character style), my ideal GREP search would produce a match after the number 6.

    How to do this?

    Define your character style in the Format Panel find, use this GREP: \s$

    $ is the match end-of-string location, and when you search for text in a style character style, the end of what this style is applied to is considered the end of the string.

    Peter

  • Select the last character of a string

    Hello
    I want to select the last character of a string address. "For example, as a result of select ' 165 John Ave W '-'W '. I tried to use the RIGHT but it does not work. I am using sqlplus.

    SELECT RIGHT(ADDRESS,1) FROM addresses;
    ORA-00904: "RIGHT": invalid identifier

    I can't find that any select statement to get the result I want. Ideas?

    Thank you!

    You want: SUBSTR (, - 1).

  • After the last updates of windows have problems with start up and now drivers

    Hello

    After the last updates of windows have problems with start up and now drivers. I get an error code 21 when I try to install the drivers AMD apparently missing.

    May 14, last night I had several (automatically) downloaded windows update

    Today, I was unable to boot my computer with Windows - tried the disk check, start checks etc, and eventually had to use System Restore (for help before the critical update to restore).

    Perfection, everything works, but knowing that windows will attempt to redo an automatic update, tried to check online - no one seemed to have a problem and (naivly) thinking I could always do another restore of the system, I rebooted again.

    Same thing worse. Could not do a sys restore either just before restarting or last night. Chose a date earlier (last week) but then lost the USB drivers and pilots display. Downloaded updated but refuses to let my AMD driver install Windows I have a very unpleasant screen... and I must now stop the installation of this update "critical."

    Would appreciate advice how do my installed display driver or whether anyone else has problems following this update

    Thank you

    Hi Jane,

    You have a disk to install Windows 7 with you?

    I suggest you to check the event viewer for error details report.

    Open event viewer.

    http://Windows.Microsoft.com/en-us/Windows7/open-Event-Viewer

  • replace only the last 3 characters within a string

    Hi all
    I have the string "abcdef_01". How can I replace the last 3 characters with "000"? in this string, for example "_01" should be replaced by '000'. Any way to do it, without the concatenation of the original string with the last 3 characters replaced by "000"?
    Thank you

    Edited by: Roger22 the 18.10.2011 09:29

    Yes, you can...

    SELECT rpad(substr('abcdef_01',1,length('abcdef_01')-3),length('abcdef_01'),chr(dbms_random.value(32,64))
                                                                             || chr(dbms_random.value(32,64))
                                                                             || chr(dbms_random.value(32,64)))
    FROM dual;
    

    RPAD/lpad may use a third parameter that is longer than 1 character and - if the duration of param 1 + length of parameter 3 is longer that parameter 2 - truncates the result to fit the length of parameter 2.

    HTH

  • replacement of the same value in a string variable values

    If I have a string:

    "%s is %s that I'm talking about."

    and - I want to replace the instances with DIFFERENT values %s... What is the best way to do it.

    I thought of her analysis in separate using substr and instr chains, but I don't know if that's an exaggeration or not.

    Replace is ideal but - it replaces all occurrences of if - you can indicate just replace the first occurrence of a value, and the second with one another (i.e. If the result after replacement of the string above was supposed to be "it's the chain that I'm talking about"

    Any help is appreciated.

    Thank you

    Hello

    wtlshiers wrote:
    If I have a string:

    "%s is %s that I'm talking about."

    and - I want to replace the instances with DIFFERENT values %s... What is the best way to do it.

    Whenever you have any questions, please post CREATE TABLE and INSERT statements for some examples of data and the results desired from these data.
    Explain how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.3.0).
    See the FAQ forum {message identifier: = 9360002}

    I thought of her analysis in separate using substr and instr chains, but I don't know if that's an exaggeration or not.

    Depending on your needs, you may need to do this.

    Replace is ideal but - it replaces all occurrences of if - you can indicate just replace the first occurrence of a value, and the second with one another (i.e. If the result after replacement of the string above was supposed to be "it's the chain that I'm talking about"

    As you say, REPLACE replaces all occurrences. There is no way to say (for example) to change only the first.
    REGEXP_REPLACE, is much more flexible. There is no option for giving a specific occurrence, but you won't even have this feature. You want maybe just something like

    REGEXP_REPLACE ( '%s is the %s I am referring to'
                , '(.*)%s(.*)%s(.*)'
                , '\1This\2string\3'
                )
    

    Depends on your data and your needs.
    Are the new values (e.g. 'This' and 'chain') fixed, or if they can change from one line to the other?
    You will always have 2 (or certain known number) of ' %s in the original string?
    '%' Always report something that needs to be replaced? If not, how can you tell when he does and when it doesn't?
    Of ' always come right after "%"? If this is not the case, what are the possibilities, and what the different characters?

  • How to select the last items of a string

    Hi guys

    I use the RS232 UART Protocol and I need to calculate the checksum. My data came in decimal form and in the end, it must be duplicated to handle. So my problem is, for example, the sum of all elemants is decimal 1742 in hexadecimal is 6CE and I used only the last two elemants, which corresponds to 206, which is the result of my check. Can someone help me?

    Thank you


  • Is there a way to define a text variable to pick up the last instance on a previous page?

    Hello

    I have a text variable to pick up at once in a document (which is defined with a character style). It's sort of schedule with multiple entries per hour.

    It works very well, however, its pages and pages of text, some of them wearing top of the previous page. For example, a page can start with 08:00 and the header is defined at 08:00, that works. 08:00 until almost the end of the next page, but 3 lines from the bottom is 09:00 in this case, I would still like this page to say at 08:00 and I would like to the next page to tell even if the first instance of the style of time on this page is from 10:00 to 09:00

    Any ideas if this is possible?

    Thank you! Much appreciated!

    Probably not without adding a non-printable tag at 08:00 in the page. ID running header variables are defined to use the page in progress, or look back only if there is no instance on the current page.

  • Find the last character in a string aplhanumreic

    Hi guys first time poster long time hiding in the shadows, I hope someone can help me

    I put the stored username and I need to find the last character before the number, for example

    ABC123 that I would like to find c
    AB123 I would find b

    suggestions as to how I could do this?
    Thanks in advance

    Here's one way:












  • I can not open the last closed tab, does not begin with the tabs

    Recently, I noticed that I can not open the last closed tab (the choice is there, but is grayed out).
    Then, during the restart, I notice that the system does not restore the tabs visited - even if this choice is made in the Options.

    I recently installed KeePass and its extension in Firefox and it seems to work (I don't actually use it often). And, recently, I had a problem where the system would resize my pages (as if I hold down the CTRL key while scrolling to me.

    Several reboots corrected this problem - but now I can't resize by pressing the Ctrl and scrolling (while holding the Ctrl key and tapping the - key will be resize the window).

    Any ideas on how to solve this problem without a complete reinstall? I have been copying my Firefox profile from one computer to another over the years and I am worried about losing my data / preferences.

    Thanks in advance!

    -John

    Uninstalled KeeFox and the problem disappeared.

  • After worsening in the last month that I finally drop with Firefox - 2 hours trying to get today and still not satisfactory - what happens?

    It is impossible for me to put in operation these days and get an instant response. The faster this last month has been an hour - after will disappear and return at intervals. It seems to go better after 08:00 but that it no good for one early don't like me - I should be able to connect at any time, but I can't. As I'm not technically mind I pay someone to come and fix this - and they seem to do it but then it would be when they visit later in the day - but as soon as they are out of the door he's back. I was recommended to use Firefox as it is no longer compatible for my use and served for three years, but now I'm going back to what I've already used on the need, of despair and frustration. Shockwave flash may be busy... plugins does not respond. I am happy to see the back of all this, but such a shame really.

    You seem to be using a very old Firefox profile folder.

    For example, your system details list shows security.enable_ssl2: True and SSL2 did not had been in charge for a while now (Firefox 8 +), so it might be a good reason (opportunity) to start with a fresh profile, through a refresh or through the Profile Manager.

    Reset is not too difficult and requires to open help > troubleshooting information page.
    This page has a reset button to reset Firefox and create a new profile.

    Another possibility is to hold down the SHIFT key pressed when Firefox starts with a double click on the shortcut on the desktop.

    This gives the Safe Boot Mode dialog box that also has a button Reset Firefox.

    When you reset Firefox and a new profile is created and some personal data (bookmarks, history, cookies, passwords, data form) are automatically imported and the current profile folder will be moved on the desktop to a folder "Old data Firefox".

    Installed extensions and other customizations (toolbars, Pref.) that you have made are lost and must be redone.

    It is possible to recover more data from the old profile, but be always careful not to copy the files corrupted to avoid transporting on the problem.

  • How do the average of the last 5 values of a column as new values automatically entered?

    If the issue is not clear for you, here's a site I found that teaches you how do it on excel. ml https://www.extendoffice.com/documents/Excel/2533-Excel-average-last-5-values.HT    I can't find the corresponding method on the good numbers. Thank you for your response in advance :-)

    Hi Z_J,

    This number approach pulls the last 5 (low) values of table 1 in another table where the average can be calculated.

    Step 1. Add line numbers in column A of table 1. This gives a way for table 1-1 to extract the last 5 values.

    Formula in A2 (and fill down

    = ROW()

    Step 2.

    In table 1-1, the formula in A6 estimated the maximum line in table 1

    = MAX (Table 1::A)

    The formula in A5 (and filling up)

    = A6−1

    Formula in B2 of table 1-1 (and fill down) using VLOOKUP to find a match for each line number in table 1-1 and get the value out of this line in table 1.

    = VLOOKUP(A2,Table 1::A:B,2,FALSE)

    Step 3.

    Now add another row (and insert a new value) to the lower part of table 1

    Lines 3 to 7 are now drawn.

    Ranger by hiding some columns

    Kind regards

    Ian.

Maybe you are looking for