Replace after specific string

Hello people,
I have the below query on 9i:
SELECT ERRMESSAGE FROM USER_LOG;And it will return:
http://somepath/somepath/somepath/somepath.aspx form visit at:prod - Client:10.10.101.243
http://someotherpath/someotherpath/someotherpath/someotherpath.aspx form visit at:prod - Client:10.20.11.203
2500 more recordsI want to remove everything after the .aspx so that only the URL part remains. e.g:
http://somepath/somepath/somepath/somepath.aspx
http://someotherpath/someotherpath/someotherpath/someotherpath.aspx
...Thank you in advance for your help

>
drbiloukos wrote:      
After the trim I saw that I also have .asp as well.
How can I have both reported ?
>
Try this way.
with user_log as
(   select 'http://somepath/somepath/somepath/somepath.aspx form visit at:prod - Client:10.10.101.243' ERRMESSAGE from dual union all
    select 'http://someotherpath/someotherpath/someotherpath/someotherpath.aspx form visit at:prod - Client:10.20.11.203' ERRMESSAGE  from dual union all
    select 'http://someotherpath/someotherpath/someotherpath/someotherpath.asp form visit at:prod - Client:10.20.11.203' ERRMESSAGE  from dual
SELECT
   CASE 
    WHEN  INSTR(errmessage,'.aspx')>0 THEN
      SUBSTR(errmessage,1,INSTR(errmessage,'.aspx') + length('.aspx') )
    WHEN INSTR(errmessage,'.asp')>0 THEN
      SUBSTR(errmessage,1,INSTR(errmessage,'.asp') + length('.asp') )
    ELSE   
      errmessage
    END AS   trimmed_errmessage
FROM
    user_log
/ Edited by: Lokanath Giri on १३ दिसंबर, २०११ ४:३८ अपराह्न

Similar Messages

  • Regular Expression - Select two words after specific string

    Hi,
    I am trying to select the two words/strings after the first word "door". I am using the search pattern (?<=door).\w+ but in this case I get the complete text after the word "door". I only want to select the two words after the first "door" in the complete text.
    Can anybody help me?
    Thanks!
    Marco Snels

    Hi Marco,
    I'm relatively handy with RegEx but this seems like a problem where I would employ a little bit of RegEx and CTL, just to make life easier.
    You can use the following RegEx (note: I didn't test this in Integrator, only in a RegEx testing tool) to extract the two words after door (but including door, unfortunately):
    (?:door)[\s]\w+[\s]\w+
    This would give you something like the following in your extracted field:
    door is brown
    You could then pass through a re-formatter to remove "door" and the whitespace and be on your way. Not the best answer but should perform reasonably well and get you up and going.
    Regards,
    Patrick Rafferty
    http://branchbird.com

  • Replace specific string in a file while reading it

    Hi,
    I am kind of an in between learner & intermediate programmer. I am trying to replace a specific string pattern in a file by reading it using BufferedReader & BufferedWriter. I tried it for 2 days. Can anyone give me a piece of code which reads a file line by line and replaces the specific string format with other? I tried replaceAll(regex,replacement). Nothing is working.

    Hi Torajirou,
    Thanks for the code. But, looks like
    . But, looks like it is giving me a static method
    problem. It says a static method should beaccessed
    in a static way(f1.replace in main). Here is the
    code. Can you help me with this?
    import java.io.*;
    public class FileReadWrite1{
    public static void replace(File file, Stringregex,
    String replacement) throws
    FileNotFoundException,IOException {
         if (file == null) {
    throw new IllegalArgumentException("File should
    uld not be null.");
         if (!file.exists()) {
    throw new FileNotFoundException ("File does not
    not exist: " + file);
         if (!file.isFile()) {
    throw new IllegalArgumentException("Should not be
    be a directory: " + file);
         if (!file.canWrite()) {
    throw new IllegalArgumentException("File cannot be
    be written: " + file);
    File tempFile = File.createTempFile("temp",
    mp", "temp");
    BufferedReader reader = new BufferedReader(new
    (new FileReader(file));
    BufferedWriter writer = new BufferedWriter(new
    (new FileWriter(tempFile));
    try{
    while (true) {
    String line = reader.readLine();
    if (line == null) {
    break;
    line = line.replaceAll(regex,replacement);
    writer.write(line);
    writer.newLine();
    writer.close();
    reader.close();
    file.delete();
    tempFile.renameTo(file);
    }catch (Exception e) {
         System.out.println("Exception occured :"+e);
    public static void main(String[] args) {
         FileReadWrite1 f1 = new FileReadWrite1();
         File file = new File("C:\\Temp\\src1.txt");
         String regex = "us.mi.state";
         String replacement = "us.tx.state";
         f1.replace(file,regex,replacement);
    }when I wrote it, I was sober and bored
    now I'm drunk and amused
    god
    did you try and remove the magic "static" keyword ?
    I wrote it static because I didn't refer to any class
    member when I wrote it and that's what I felt
    compelled to do, though I feel nowadays writing
    anyting static suggests some design mistake
    somewhere
    blahblahblahblahblahs/blahblahblahblahblah/blahblahblahblahblahblah
    (forgot a "blah")

  • Two finger swipe replaces google search string

    MBP with Safari 6.0 experiencing this problem.  Another user was experiencing the issue here:
    http://www.ehmac.ca/mac-iphone-ipad-ipod-help-troubleshooting/99937-safari-two-f inger-swipe-bug-replaces-google-search-string-os-10-7-3-a.html
    I don't know where the bug reports are to follow up on it and I haven't seen any patches for it.  Any advice?  Specifically, I'd like to know how to file the bug (in case I find another) and to follow up on any existing issues.
    TIA,
    Scott

    Is there no place to track the status of the report or see any other outstanding issues so I don't bother filing duplicates?
    Never heard of such a function here. This method gets feedback to the people who count but it is completely behind the scenes. Part of Apple's "cards close to the chest" method of doing pretty much everything. You should have been looking at the "don't expect a response" screen after you hit the submit button on your bug report.
    If there is something that needs clarification, I suspect they will use e-mail to ask for it, but don't stay home waiting!
    Have you read Walter Isaacson's  biography of Steve Jobs? Things like this took on a new--if not satisfying--perspective for me after reading it. So far, it has persisted in their corporate culture in the after-Steve era..

  • How Can I replace newScale Text Strings with Custom Values?

    How Can I replace newScale Text Strings with Custom Values?
    How can I replace newScale text strings with custom values?
    All  newScale text is customizable. Follow the procedure below to change the  value of any text string that appears in RequestCenter online pages.
    Procedure
    1. Find out the String ID of the text string you would like to overwrite by turning on the String ID display:
    a) Navigate to the RequestCenter.ear/config directory.
    b) Open the newscale.properties file and add the following name-value pair at the end of the file:res.format=2
    c) Save the file.
    d) Repeat steps b and c for the RmiConfig.prop and RequestCenter.prop files.
    e) Stop and restart the RequestCenter service.
    f) Log  in to RequestCenter and browse to the page that has the text you want  to overwrite. In front of the text you will now see the String ID.
    g) Note down the String ID's you want to change.
    2. Navigate to the directory: /RequestCenter.ear/RequestCenter.war/WEB-INF/classes/com/newscale/bfw.
    3. Create the following sub-directory: res/resources
    4. Create the following empty text files in the directory you just created:
    RequestCenter_0.properties
    RequestCenter_1.properties
    RequestCenter_2.properties
    RequestCenter_3.properties
    RequestCenter_4.properties
    RequestCenter_5.properties
    RequestCenter_6.properties
    RequestCenter_7.properties
    5. Add the custom text strings to the appropriate  RequestCenter_<Number>.properties file in the following manner  (name-value pair) StringID=YourCustomTextString
    Example: The StringID for "Available Work" in ServiceManager is 699.
    If you wanted to change "Available Work" to "General Inbox", you  would add the following line to the RequestCenter_0.properties file
         699=General Inbox
    Strings are divided into the following files, based on their numeric ID:
    Strings are divided into the following files, based on their numeric ID:
    String ID  File Name
    0 to 999 -> RequestCenter_0.properties
    1000 to 1999 -> RequestCenter_1.properties
    2000 to 2999 -> RequestCenter_2.properties
    3000 to 3999 -> RequestCenter_3.properties
    4000 to 4999 -> RequestCenter_4.properties
    5000 to 5999 -> RequestCenter_5.properties
    6000 to 6999 -> RequestCenter_6.properties
    7000 to 7999 -> RequestCenter_7.properties
    6. Turn off the String ID display by removing (or commenting out) the line "res.format=2" from the newscale.properties, RequestCenter.prop and RmiConfig.prop files
    7. Restart RequestCenter.
    Your customized text should be displayed.

    I've recently come across this information and it was very helpful in changing some of the inline text.
    However, one place that seemed out of reach with this method was the three main buttons on an "Order" page.  Specifically the "Add & Review Order" button was confusing some of our users.
    Through the use of JavaScript we were able to modify the label of this button.  We placed JS in the footer.html file that changes the value of the butt

  • Replace the connection string in Excel MDS file

    I had MDS solution from one SQL Server 2012 to another - SQL Server 2014. I have configured Excel file with connection to MDS. How can I safely to replace the connection string in my Excel MDS file and the tables is not broken?
    from Moscow with money

    Hi,
    Excel is just used to manage data and create new entities and attributes. Why not first publish and close your excel before MDS upgraded to 2014? After the upgrade, reconnect new solution in your excel.
    thanks,
    Jerry

  • Replace charcter from string in 46c

    Hi,
    If you could send me code for below scanerio that will be great.
    in 46c i have string '/ABCD/te_12' now i want to replace the '/' with '+'  and '_' with '|', can you tell me how to do this.
    thanks,
    john

    hi check the replace statement... hit F1 on replace and make ur code..
    Basic form
    REPLACE f WITH g INTO h.
    Addition
    ... LENGTH len (length specification for field f )
    Effect
    Replaces the first occurrence of the contents of field f in field h with the contents of field g . All fields are handled in their defined length; this means that closing blanks are not ignored.
    The return code value indicates whether the string f was found in h and replaced by g :
    SY-SUBRC = 0 String replaced.
    SY_SUBRC = 4 String not replaced.
    Example
        DATA FIELD(10).
        MOVE 'ABCB' TO FIELD.
        REPLACE 'B' WITH 'string' INTO FIELD.
    returns:
    FIELD = 'AstringCB', SY-SUBRC = 0
    Note
    The fields f and g in the REPLACE statement should not overlap. Otherwise, the result is undefined.
    Addition
    ... LENGTH len ... (length specification for field f )
    Effect
    Searches for the string f in the field h not in its (full) field length, but in the length len .
    Example
        DATA: PATTERN(5) VALUE 'ABC',
              LEN TYPE I,
              REPL_STRING(5) VALUE '12345',
              FIELD(12) VALUE 'abcdeABCDE'.
        REPLACE PATTERN WITH REPL_STRING
                        INTO FIELD.
    does not change FIELD , since 'ABC ' does not occur in abcdeABCDE ' .
        LEN = STRLEN( PATTERN ).
        REPLACE PATTERN LENGTH LEN
                        WITH REPL_STRING
                        INTO FIELD.

  • Search given string array and replace with another string array using Regex

    Hi All,
    I want to search the given string array and replace with another string array using regex in java
    for example,
    String news = "If you wish to search for any of these characters, they must be preceded by the character to be interpreted"
    String fromValue[] = {"you", "search", "for", "any"}
    String toValue[] = {"me", "dont search", "never", "trip"}
    so the string "you" needs to be converted to "me" i.e you --> me. Similarly
    you --> me
    search --> don't search
    for --> never
    any --> trip
    I want a SINGLE Regular Expression with search and replaces and returns a SINGLE String after replacing all.
    I don't like to iterate one by one and applying regex for each from and to value. Instead i want to iterate the array and form a SINGLE Regulare expression and use to replace the contents of the Entire String.
    One Single regular expression which matches the pattern and solve the issue.
    the output should be as:
    If me wish to don't search never trip etc...,
    Please help me to resolve this.
    Thanks In Advance,
    Kathir

    As stated, no, it can't be done. But that doesn't mean you have to make a separate pass over the input for each word you want to replace. You can employ a regex that matches any word, then use the lower-level Matcher methods to replace the word or not depending on what was matched. Here's an example: import java.util.*;
    import java.util.regex.*;
    public class Test
      static final List<String> oldWords =
          Arrays.asList("you", "search", "for", "any");
      static final List<String> newWords =
          Arrays.asList("me", "dont search", "never", "trip");
      public static void main(String[] args) throws Exception
        String str = "If you wish to search for any of these characters, "
            + "they must be preceded by the character to be interpreted";
        System.out.println(doReplace(str));
      public static String doReplace(String str)
        Pattern p = Pattern.compile("\\b\\w+\\b");
        Matcher m = p.matcher(str);
        StringBuffer sb = new StringBuffer();
        while (m.find())
          int pos = oldWords.indexOf(m.group());
          if (pos > -1)
            m.appendReplacement(sb, "");
            sb.append(newWords.get(pos));
        m.appendTail(sb);
        return sb.toString();
    } This is just a demonstration of the technique; a real-world solution would require a more complicated regex, and I would probably use a Map instead of the two Lists (or arrays).

  • How to replace mixed chars string

    Hi All,
    I want to replace mixed chars string from each row and want to replace with new string.
    Ex : The existing string might be in different cases like "Abc string", "abc string", "aBC string". I want to search for all these string types and want to replace with new string "Abc string".
    Could anyone give suggestions on this.
    Thanks,
    Prakash

    [url http://download.oracle.com/docs/cd/E11882_01/server.112/e26088/functions149.htm#i1305521]REGEXP_REPLACE supports case insensitive replacing.
    REGEXP_REPLACE(source_string,'abc string','Abc string',1,0,'i')The *'i'* specifies case insensitive replacing, so it will find all of "Abc string", "abc string", "aBC string" :-)

  • Replace " from the string

    Hi,  I am not able to remove " (double quotes) from a sting.
    I am using replace function in webi but getting error.
    example sting: Yellow stone"discovery"
    i have tried like this: =replace([varible];""";"")  but getting error. can anybody help me in removing the " from sting.
    Thanks.

    Description
    Replaces part of a string with another string
    Function Group
    Character
    Syntax
    string Replace(string input_string; string string_to_replace; string replace_with)
    EX:=Replace ([[variable]]; Char(34) ;"")
    Input
    input_string                     The input string 
    string_to_replace             The string within input_string to be replaced 
    replace_with                    The string to replace string_to_replace with. 
    Output
    The string with the part replaced
    Example
    Replace ("New YORK";"ORK";"ork") returns "New York"
    All the best,
    Praveen

  • Urgent: deleting a specific string form an existing .txt file

    Plz help me with a sample code on how to delete a specific string form an existing .txt file..it is very urgent...
    thanks in advance

    String path = "D:\\text.txt";
    File file = new File(path);
    BufferedReader br = new BufferedReader(new FileReader(file));
    String line = "";
    String text = "";
    while((line = br.readLine()) != null) {
    text += line + "\n";
    br.close();
    String textToFind = "find";
    int start = text.indexOf(textToFind);
    if(start != -1) {
    text = text.substring(0, start) + text.substring(start + textToFind.length());
    BufferedWriter bw = new BufferedWriter(new FileWriter(file));
    bw.write(text, 0, text.length());
    bw.close();
    }

  • HT204053 iPhone 5s replaced after one month at apple store. They started restore and it is still restoring after 24 hours.

    iPhone 5s replaced after one month at apple store. They started restore and it is still restoring after 24 hours. What can I do?

    If you feel the restore process is not progressing, all you can do is stop it and try again.  To stop the restore, go to Settings>iCloud>Storage & Backup and tap Stop Restoring iPhone at the bottom.  Then go to Settings>General>Reset, tap Erase All Content and Settings, go through the setup screens on the phone and when given the option, choose Restore from iCloud Backup and follow the prompts.  Be sure your phone is connected to wifi and your charger while it is restoring the backup.

  • Script to delete users created in database after specific days

    Hi,
    I am working as a QA. In my team, we need to create oracle users frequently for testing purpose but no one deletes user from oracle after finishing testing thus creating lots of user in oracle and also wasting lots of space. so need help to create a script which will delete user defined table after specific days which we can set in script ?
    Early response will be appreciable.
    Thanks in advance

    Its a oracle users which are created by team members for testing purposeprogramatically how will you differentiate between schemas/usernames created by Oracle & those created locally?
    SQL> select username, created from dba_users order by 2;
    USERNAME                 CREATED
    SYSTEM                      15-AUG-09
    SYS                      15-AUG-09
    OUTLN                      15-AUG-09
    DIP                      15-AUG-09
    ORACLE_OCM                 15-AUG-09
    DBSNMP                      15-AUG-09
    APPQOSSYS                 15-AUG-09
    WMSYS                      15-AUG-09
    EXFSYS                      15-AUG-09
    CTXSYS                      15-AUG-09
    ANONYMOUS                 15-AUG-09
    XDB                      15-AUG-09
    XS$NULL                  15-AUG-09
    MDSYS                      15-AUG-09
    ORDSYS                      15-AUG-09
    SI_INFORMTN_SCHEMA            15-AUG-09
    ORDDATA                  15-AUG-09
    ORDPLUGINS                 15-AUG-09
    OLAPSYS                  15-AUG-09
    MDDATA                      15-AUG-09
    SPATIAL_WFS_ADMIN_USR            15-AUG-09
    SPATIAL_CSW_ADMIN_USR            15-AUG-09
    SYSMAN                      15-AUG-09
    MGMT_VIEW                 15-AUG-09
    APEX_030200                 15-AUG-09
    APEX_PUBLIC_USER            15-AUG-09
    FLOWS_FILES                 15-AUG-09
    OWBSYS                      15-AUG-09
    OWBSYS_AUDIT                 15-AUG-09
    SCOTT                      15-AUG-09
    IX                      07-MAY-10
    BI                      07-MAY-10
    SH                      07-MAY-10
    HR                      07-MAY-10
    PM                      07-MAY-10
    OE                      07-MAY-10
    DBADMIN                  07-MAY-10
    BONGO                      22-MAY-10
    USER1                      30-AUG-10
    SAM                      29-SEP-10
    40 rows selected.which "old" schemas need to be discarded.
    post SELECT that properly produces usernames to be removed.

  • [invalid] Run systemd service after specific device is initialized

    Hi.
    Is there any way to run systemd service only after specific device is initialized/kernel module is loaded?
    The task I'm trying to solve is applying trackpoint speed and sensitivity settings on boot in my X220.
    Service code (trackpoint.service) is quite simple
    [Unit]
    Description=Trackpoint configuration
    [Service]
    Type=oneshot
    EnvironmentFile=/etc/conf.d/trackpoint.conf
    ExecStart=/bin/sh -c 'echo ${sensitivity} > /sys/devices/platform/i8042/serio1/serio2/sensitivity'
    ExecStart=/bin/sh -c 'echo ${speed} > /sys/devices/platform/i8042/serio1/serio2/speed'
    [Install]
    WantedBy=graphical.target
    The issue is that trackpoint.service gets executed before trackpoint device gets initialized and thus fails.
    Jun 14 23:12:10 xi sh[414]: /bin/sh: /sys/devices/platform/i8042/serio1/serio2/sensitivity: No such file or directory
    Jun 14 23:12:10 xi systemd[1]: Unit trackpoint.service entered failed state.
    Jun 14 23:12:18 xi kernel: psmouse serio2: trackpoint: IBM TrackPoint firmware: 0x0e, buttons: 3/3
    Jun 14 23:12:18 xi kernel: input: TPPS/2 IBM TrackPoint as /devices/platform/i8042/serio1/serio2/input/input13
    What have I tried already
    1. Specified systemd-modules-load in After= and Requires= directives and added psmouse module to /etc/modules-load.d
    2. Tried path activation (perhaps, I did it wrong) by creating i8042.path
    [Path]
    PathExists=/sys/devices/platform/i8042
    Unit=trackpoint.service
    However, this changed nothing.
    I don't know what else should I try.
    Please suggest solution for this.
    Thanks in advance.
    Last edited by eDio (2013-06-15 13:28:36)

    Thank you very much.
    I've finally managed this to work
    $ cat /etc/udev/rules.d/10-trackpoint.rules
    SUBSYSTEM=="input", KERNEL=="event13", ACTION=="add", RUN+="/usr/bin/trackpoint_apply"
    $ cat /etc/conf.d/trackpoint.conf
    speed=255
    sensitivity=255
    $ cat /usr/bin/trackpoint_apply
    #!/usr/bin/env sh
    . /etc/conf.d/trackpoint.conf
    /usr/bin/echo $speed > /sys/devices/platform/i8042/serio1/serio2/sensitivity
    /usr/bin/echo $sensitivity > /sys/devices/platform/i8042/serio1/serio2/speed

  • How to replace in a String

    I really want to know how to replace " in a String with replaceAll()
    I want to replace " with \"
    Unortunately I am not able to do it with :
    xml = xml.replaceAll("\"", "\\\"");Can u please suggest something
    thanks

    public class Test {
    public static void main(String[] args) {
       System.out.println("abc>def".replaceAll(">","\"+"));
    }Output:
    abc"+def

Maybe you are looking for