regexp_substr - how to search for two different words and result based on returning a different part of the string

Hello everyone

I fight with this regexp_substr and I wonder if there is a way to deal with it. I have two string type in a column with the following structure:

structure 1 always starts with "app.catalog.school.", as the following three examples

app.catalog.school.DB.BT

app.catalog.school.B.FTA

app.catalog.school.ACA.CD

structure 2 always begins with "app.catalog.admin.", as the following three examples

app.catalog.admin.C.ABC

app.catalog.admin.BT.AP

app.catalog.admin.MI.RT

If the value of the field begins with "app.catalog.school." it should return everything after the last period (.) as follows

BT

FREE TRADE AGREEMENT

CD

If the value of the field begins with "app.catalog.admin." it should return the string between the third and fourth period (.) as follows

C

BT

MI

I actually have a solution to this:

decode)

regexp_substr (myfield, ' [^.] +' 1, 3), 'school', regexp_substr (myfield, ' [^.] +' 1, 5), "admin", regexp_substr (myfield, ' [^.] +' 1, 4)

)

I am not happy with the solution above using decode(). I think I should be able to solve this problem purely with reg_exp but after hours to try again without success. You have better solution/suggestion?

I use Oracle version 10.2. Thank you very much.

Oops: Oracle version 10.2, here to use regexp_replace

WITH testdata UNTIL
(SELECT 'app.catalog.school.DB.BT' FROM DUAL str

UNION ALL

SELECT 'app.catalog.admin.C.ABC' FROM DUAL
)

Select
Str
, regexp_replace (str, ' ^. * (admin | school\.)) [ ^.] +)\. ([^.] +). (* $', "\2") res
of testdata

RES STR

"app.catalog.school.DB.BT" 'BT '.

'app.catalog.admin.C.ABC' 'C '.

to 11.x, we can use regexp_substr because he has this subexpression setting more pure accident.

WITH testdata UNTIL
(SELECT 'app.catalog.school.DB.BT' FROM DUAL str

UNION ALL

SELECT 'app.catalog.admin.C.ABC' FROM DUAL
)

Select
Str
, regexp_substr (str, ' (admin | school\.)) [ ^.] +)\. ([^.] +)', 1, 1, null, res) 2.
of testdata

STR RES
app.catalog.school.DB.BT BT
app.catalog.admin.C.ABC C

Post edited by: extended chris227

Tags: Database

Similar Questions

  • possible to have 2 different application fields for two different clips at the same time

    Hello

    possible to have 2 different application fields for two different clips at the same time for the classification match in terms of the scope, only not to the eye?

    Not that I know of.  And Yes, it would be very useful. As would the ability to go back 2 in reading monitor and a button "game clip under the read head 1. Sigh.

    Neil

  • How to divide the screen into two parts in order to see the two different parts of the same file? [Suggestion] [Android]

    I am Brazilian and I use Adobe Acrobat Reader DC a lot. I would suggest an implementation of features present in the PC, I missed a lot of things on Android, which is 'New window' or something like that, like split the screen into two parts in order to see the two different parts of the same file.

    For smartphones, its use is restricted, but for tablets, it can be really useful, because it allows the display of two distinct points of the same file,

    I have reduced considerably the use of paper using this application, however, I need to navigate the file always pick up a few points seen earlier, which causes a lot of discomfort compared to printed documents.

    This is a suggestion, but I would like it to be considered.

    Thank you for your request. We have taken note of the same and must try to integrate it into one of our future releases.

    Thank you.

  • How to search for a specific word in the code using Dreamweaver?

    I need to search for a specific word in the code for all the pages of my site. How can I do it using Dreamweaver?

    To search for local files of a Site defined in DW...

    Open the search tool & replacement with Ctrl + F

    Replace the drop-down list search in entire current Local Site

    Replace the drop-down list of search text or Source code

    Add the text to search for in the search field

    Add the replacement text in the field replace (or nothing if you just want to remove the text)

    Hit replace all

  • How to search for a particular word by selecting multiple text files

    Hello

    I have hundreads of text files and I need to search a particular word in these bunch of txt files.

    How do so by selecting all files and search for the word. I do not want to open each file and search for the word.

    I use Windows 7 here.

    Please suggest.

    Thank you...

    Anand

    I don't think that we are able to select the files to search, but what you can do, is have all files in a folder that is searched for.  Open a window for the folder that contains the files and use the Windows search box in the upper right of this window.  If you are looking for 'bread', enter:

    content: bread

    At the same time, if you want to restrict the search to the txt files, then enter

    content: bread ext:txt

    For more details you can read my reply to

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-files/how-do-i-search-all-of-my-documents-for-a-specific/7ba6c244-07fd-4F52-988d-e2e303b4bec9

  • One login for two different sites of the BC

    I have a client who has created two different sites of BC due to the product of the limit of two Types of pricing. Site 1 has the retail and dealer price and location 2 is distributor and master distributor prices.

    Site 1 is the main and has documents in a neighborhood secure requiring access to all levels of the four user, my client would like to allow customers to have a single login for both sites for users of site 2 can access documents in a space secured on site 1 without having to maintain two connections.

    Anyone know if it's feasible say with a biscuit or a special script?

    Thank you

    Barry

    Barry H, you must set up a system which hangs in the API of so, but that is at the heart of CRM and interacts with both sites.

  • Windows experience index for two different laptops with the same configuration of maximum output power

    [I have two almost identical laptops Lenovo T61p and running W7 64 Ultimate b: has] has an Intel T7700 processor and 8 GB of RAM. [B] has a CPU of Intel T8300 with 4 GB of RAM. They are clocked at 2.6 GHz and have identical hard drives.

    When the system is running Windows Experience Index, it does to 2.6 GHz. It doesn't matter what is the result.

    When the system B runs the WEI, it becomes 780 MHz. In the end, he will return to run at 2.6 GHz. Needless to say that it will reduce its index to I / 2 of the other system. During any normal operation, the processor remains a 2.6 GHz

    All other values of the indices are similar and irrelevant.

    As far as I checked, the two system has the same configuration of power to maximum performance, I did not miss something. MSCONFIG are also identical.

    Any ideas about where to look to fix this behavior?

    See you soon

    Rolando

    WEI is a meaningless number that does not reflect anything in reality.  You win nothing in this hunt.  Because it is a useless number, that it has been deleted in windows 8

  • How can I add two different colors on the same object?

    Hello

    Say if I have something that I have a circle and I want the black semicircle and the other half with white. How can I do this?

    Thank you

    actually, sorry, forget something: you can fill it with a gradient that has two color stops in the same place. It is maybe a little more ordered according to what you need.

  • Is there a way to search for a specific word in a text file on an iPhone?

    I just bought an iPhone 6 Plus and have some TextEdit/RTF files in iCloud. I opened one on the phone butI cannot know how he search for a specific word or group of words. Is there a way to do this?

    Thank you.

    You open files with what app?

  • How to search for a Word document in Windows 8?

    I'm stumbling around Windows 8 that came pre-loaded on my new laptop.  I ordered Windows and Excel to be included in the package.  I saved a number of documents in Word, and now I need to get these documents for a particular.  I looked on the Internet and found a lot of no-help, that is to say, 'go in search of a file'.  Excuse me, but if I could find searching a file, I could probably find out how to search for the file, Huh?  Thus,.

    Could someone please help me with: how to find a Word document (1) and (2) where is the infamous "search"?

    I did the thing 'sweep to the right side of the screen"to get those things shadow to appear, and click on the magnifying glass (which I think the engineers forgot to change when they changed everything!) and if I wanted to search for apps, I'd be in great shape.  But his files I'm looking for, Word documents.  The designers of this 'new' version improved - well, new, in all cases seem to have forgotten those of use who use computers for productive work and not socialize or play games.

    Sorry for the hike and whining, but I'm very frustrated that the tasks that were once very simple are now extremely difficult to fill.

    It's pretty easy, at the beginning screen just type the name of your document and right it will bring the search screen and you select files (files, settings, Apps). Take a look at:

    http://Windows.Microsoft.com/en-us/Windows-8/search-apps-files-settings

  • Two build for two different OS version

    Hello

    I have two different construction for two different OS version of the same application.

    It's a build for v5.0 and one for version 6.0.

    So how can I download this two builds on appworld

    can I download two builds?

    How appworld process works for different os?

    -David

    When you set your release simply add two bundles, for example MyApp50 and MyApp60. Download the file of cod for OS5.0 and speify minimum supported OS version 5.0. After that, download the 6.0 bundle and specify minimum supported OS version 6.0. And select all of the possible devices for two cod.

    App World will do the rest is the latest version that is possible for a given user, so users with 6.0 and above will receive 6.0 cod, while users with OS5.0 will receive the 5.0 file cod.

  • How can I define two different emails in one form of contact?

    How can I define two different emails in one form of contact?

    To enter several e-mail address with Contact form Widgets:

    1. Click on the Options icon for the selected widget, then
    2. In the Email box, enter several emails in delimiting them with a semicolon. For example:
      [email protected];[email protected]
      

    CARI

  • How can you tell two different cursors to move to different places?

    Sorry if this has been asked before, but I couldn't find the answer anywhere.

    As I said, I'm trying to get two different cursors to move in two different places on the same graph. I have values I want them to go, I'm not sure that work or the command to use. I'm using LabVIEW 8.6. Thanks for any help!

    WCR,

    You will need to use the property of the graph nodes to move cursors programmatically. The properties of interest are the active cursor and the cursor Position > X and the Position of the cursor > y. use the active cursor to specify (by index cursor) what slider you want to work with, and then set the X property values and, and then adjust the slider according as the active cursor and set its property values X and Y.

  • need help for where and how to search for apps you want in windows store 8

    I just bought a SAMSUNG ATIV TAB 3 (XE300TZC), it has WINDOWS 8.  I went to the store Windows on my windows 8 to start the download of all my apps that I like and I found some of the apps and downloaded. But many of the apps I want to I don't think because I've noticed that it is not an option or small box for me to be able to get all the apps... I guess my question is how a search for specific applications on my STORE of WINDOWS 8?

    Hi Brandi,

    Thanks for posting your question on the Microsoft community.

    Thank you for details on the issue.

    Please see suggestions from HairyFool said on June 4, 2013 and check.
    http://answers.Microsoft.com/en-us/Windows/Forum/windows_8-Winapps/how-do-i-search-the-Windows-apps-store-on-my/75390438-4DBA-4a77-93cd-aa3b2153efce

    I hope this information helps.

    Please let us know if you need more help.

    Thank you

  • How to search for text in all of the PDF files on a mobile device?

    How to search for text in all of the PDF files on a mobile device?

    Not possible on mobile devices.

Maybe you are looking for

  • Why do we still have a folder "unsorted bookmarks"?

    I don't understand why Firefox still has bookmarks enter this useless folder by default. No there there not complaints on this subject all the time?

  • Satellite L755D-11W: cannot change the graphics chip in the game settings

    Hello On my laptop Satellite-L755D-11W, in some games and applications does not change the graphics chip. Otherwise said, at the time to choose the right game, I want to put a high-performance and change AMD Radeon HD 6400 M-> AMD Radeon (TM) HD 6520

  • Set a static IP address for the printer

    One of the most common steps given when members of the community have printers that will remain not connected is affecting the camera a static IP address. Most of the members to respond to messages will include a document that's going to work on the

  • Pavilion dv4 recovery DVD is not recognized at startup

    I made a set of 4 HP recovery assistant recovery DVDs when my PC was brand new, and now I want to fix the system (after the failure of the CMF to repair files). However, I get an error of 0xc0000255 at startup (everything has been already verified as

  • Difficulties to remove Norton anti-virus completely

    Trying to install Kaspersky but is conflict message all Norton was uninstalled, but I get the message that Kaspersky cannot install because it detects Norton - how to make Norton completely out of my system?