To remove last '/' character

I need to remove '/' character and string comes after it. I will give an example.
CREATE TABLE TAB (COL1 VARCHAR2(50));
INSERT INTO TAB VALUES ('hIA/SS/TTTT/FFFF');
INSERT INTO TAB VALUES ('hDFF/AA/S/AAAAAAAA');
I should remove the last '/' and string comes after it so when i query , i should get result as
hiA/SS/TTTT
hDFF/AA/S
Please help me

Hi,
Welcome to the forum!
Here's one way:
SELECT     col1    -- if wanted
,     REGEXP_REPLACE ( col1
                 , '/[^/]*$'
                 )     AS up_to_last_slash
FROM     tab
;Regular expressions can be very convenient, but they can also be slow. If performance is a problem, try this instead:
SELECT     col1    -- If wanted
,     NVL ( SUBSTR ( col1
                      , 1
                      , INSTR (col1, '/', -1) - 1
         , col1
         )                  AS up_to_last_slash
FROM     tab
;This is basically what Chris posted earlier, except that it returns col1 unchanged when col1 does not contain a '/'.
Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful!
Edited by: Frank Kulash on Oct 8, 2012 7:32 AM

Similar Messages

  • Removing last character of a string

    Hi Gurus,
                 Is there any way to remove the last character of staring other that finding the string length and doing it?
    waiting for reply
    Ravi

    HI,
    yaa u can do this by one logic
    wht u do is concatenate one special symbol like $ to the string wht u have and in the next statement by using tht special symbol u can find fdpos i.e. field postion i.e. at which lenght it is there and then in again another statement u can increa fdpos by one and u can cut the string at tht length
    i think u got my logic
    further if u have any quiries u can contact me on [email protected]
    plzz reward if it is usefull....

  • Remove 1st or Last Character

    Post Author: bkormoski
    CA Forum: Formula
    I need to remove 1st and or last character in a string u2013 Example
    Original string u201CS45673-08  I need to get u201C45673u201D, I canu2019t use MID because sometimes the string is u201CS437-06 or u201CS2345-08u201Du2026 Any ideas?

    Post Author: V361
    CA Forum: Formula
    Do you always strip off the first character, and everything after (and including) the -

  • Why does Preview automatically resize the text box to cut off the last character of added text? How do I fix it?

    Why does Preview automatically resize the text box to cut off the last character of added text? How do I fix it?
    I use the Tools > Annotate > Add Text feature, and when I click away after adding text, it automatically changes the text box size such that the last letter -- or last word -- gets bumped off into an invisible line below it, forcing me to manually adjust every single text box. It is highly annoying when trying to complete PDF forms (e.g. job applications).
    It appears to be a glitch, quite honestly, an error resulting from Apple's product design. Has it been fixed in the new operating system (for which they want $30)?
    I would very much appreciate any help you can provide! Thank you for your time.

    * "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites that cause problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]

  • Checking last character

    What would you consider being the best way to check the last character of a string?
    var folderPath = '~/Desktop/Test';
    if (folderPath[folderPath.length - 1] !== '/') { folderPath += '/'; }
      or
    if (folderPath.slice(-1) !== '/') { folderPath += '/'; }
    I see that changePath() can also be used to keep track of this path separator.
    Thanks.

    Hi Hans,
    I was trying to come up with a function to move a folder and it's contents, or a file... similar to how the OS X Finder would do it.  However, I just noticed when the files are copied over, they're not the same file size as the original which makes me think it's stripping resource forks, etc.  :-(
    I'm looking now at using doScript and running ditto from the command-line with applescript.  Here's the code I was working with earlier though:
    function moveItem(oldPath, newPath) {
        newPath = newPath.toString();
        //if (newPath[newPath.length - 1] !== '/') { newPath += '/'; }
        if (newPath.slice(-1) !== '/') { newPath += '/'; }
        var oldPathType = oldPath.constructor.name;
        if (oldPathType === 'Folder') {
            newPath += (oldPath.name + '/');
            with (Folder(newPath)) {
                if (! exists) { create(); }
            for each (var i in oldPath.getFiles()) {
                if (i.constructor.name === 'Folder') {
                    moveItem(i, newPath);
                } else {
                    i.copy(newPath + i.name);
                    i.remove();
            oldPath.remove();
        } else if (oldPathType === 'File') {
            oldPath.copy(newPath + oldPath.name);
            oldPath.remove();
        } else {
            throw 'Problem moving file/folder!';

  • How to remove certain character from a string?

    Follows the table:
    CT_TRABALH
    400rj101
    400rj102
    400rj103
    400rj104
    400rj105
    400rj106
    400rj107
    400rj108
    400rj109
    400rj1010
    400rj1011
    I woulld like to make the following with its values. For example the value 400rj1010
    I would like to remove its last character (400rj101) and then relace the last zero for the last number(400rj111) by query. Is there any way I can achieve this?

    I would write something a little more generic :
    SCOTT@demo102> with tbl as
      2      (select '400rj101' as CT_TRABALH from dual union all
      3       select '400rj102' from dual union all
      4       select '400rj103' from dual union all
      5       select '400rj104' from dual union all
      6       select '400rj105' from dual union all
      7       select '400rj106' from dual union all
      8       select '400rj107' from dual union all
      9       select '400rj108' from dual union all
    10       select '400rj109' from dual union all
    11       select '400rj1010' from dual union all
    12       select '400rj10120' from dual union all
    13       select '400rj14120' from dual union all
    14       select '412rj14120' from dual union all
    15       select '400rj1011' from dual )
    16  select CT_TRABALH,
    17         case when substr(CT_TRABALH,-1,1) = '0'
    18              then  decode(instr(substr(CT_TRABALH,1,length(CT_TRABALH)-1),0,-1),
    19                           0, substr(CT_TRABALH,1,length(CT_TRABALH)-1),
    20                              substr(CT_TRABALH,1,instr(substr(CT_TRABALH,1,length(CT_TRABALH)-1),0,-1)-1)
    21                              ||substr(CT_TRABALH,-2,1)
    22                              ||substr(CT_TRABALH,instr(substr(CT_TRABALH,1,length(CT_TRABALH)-1),0,-1)+1,
    23                               length(CT_TRABALH)-instr(substr(CT_TRABALH,1,length(CT_TRABALH)-1),0,-1)-1))
    24              else CT_TRABALH
    25              end as CT_TRABALH_0
    26  from tbl;
    CT_TRABALH CT_TRABALH_0
    400rj101   400rj101
    400rj102   400rj102
    400rj103   400rj103
    400rj104   400rj104
    400rj105   400rj105
    400rj106   400rj106
    400rj107   400rj107
    400rj108   400rj108
    400rj109   400rj109
    400rj1010  400rj111
    400rj10120 400rj1212
    400rj14120 402rj1412
    412rj14120 412rj1412
    400rj1011  400rj1011
    14 rows selected.
    SCOTT@demo102> Nicolas.

  • Deleting last character of a string

    Hi Abapers,
    I want to delete the last character of my workarea and then store into table.
    The workarea says that it is FAX|
    I have to remove the last character.
    How to do tht.
    Please reply.
    Thanks

    hi
    do this in following way
    frist find the String length
    let it will be
    w_str = 'sdn is wonderfull'
    now use.
    w_len = strlen(w_str) .
    now
    w_result = w_str+0(w_len - 1).
    Cheers
    Snehi

  • Avoiding last character in a line

    Hi,
    I am printing orders as 00123, 00124, 00125, in this i want to remove the last character , besides 00125.
    I mean after the end order number comma should not print. I am printing this in an email.
    Regards
    VEnk@

    You only have to use
    REPLACE ALL OCCURRENCES OF '*' IN V_STRING WITH SPACE .
    Where v_string = '00123, 00124, 00125,'.
    This will make the value of V_string = '00123, 00124, 00125,'
    Edited by: Kapil Sharma @ Steria on Jan 28, 2010 12:46 PM

  • Bi publisher report, data table, column label displays last character

    Hello all,
    I have created various reports on BI Publisher (win2008 R2 64bit 11g (.1.1.5) version). After altering some access rights, all the reports that include data tables display only the last character of the column label. All the column data is reported correctly.
    example:
    - TotalNumber -
    4234
    234
    4
    became
    - r -
    4234
    234
    4
    Any ideas about what is going on???
    Thank you

    Thanks for the suggestion Simon.
    I just created a view based on the 46-column SELECT statement from dual above and then set "SELECT * FROM myview" as the Source Query.
    Unfortunately I get exactly the same error.
    Thanks,
    Andy

  • Best way to remove last line-feed in text file

    What is the best way to remove last line-feed in text file? (so that the last line of text is the last line, not a line-feed). The best I can come up with is: echo -n "$(cat file.txt)" > newfile.txt
    (as echo -n will remove all trailing newline characters)

    What is the best way to remove last line-feed in text file? (so that the last line of text is the last line, not a line-feed). The best I can come up with is: echo -n "$(cat file.txt)" > newfile.txt
    (as echo -n will remove all trailing newline characters)
    According to my experiments, you have removed all line terminators from the file, and replaced those between lines with a space.
    That is to say, you have turned a multi-line file into one long line with no line terminator.
    If that is what you want, and your files are not very big, then your echo statement might be all you need.
    If you need to deal with larger files, you could try using the 'tr' command, and something like
    tr '
    ' ' ' <file.txt >newfile.txt
    The only problem with this is, it will most likely give you a trailing space, as the last newline is going to be converted to a space. If that is not acceptable, then something else will have to be arranged.
    However, if you really want to maintain a multi-line file, but remove just the very last line terminator, that gets a bit more complicated. This might work for you:
    perl -ne '
    chomp;
    print "
    " if $n++ != 0;
    print;
    ' file.txt >newfile.txt
    You can use cat -e to see which lines have newlines, and you should see that the last line does not have a newline, but all the others still do.
    I guess if you really did mean to remove all newline characters and replace them with a space, except for the last line, then a modification of the above perl script would do that:
    perl -ne '
    chomp;
    print " " if $n++ != 0;
    print;
    ' file.txt >newfile.txt
    Am I even close to understanding what you are asking for?

  • Last Character In Crystal Report cut off when ran via BO web interface

    I created a report in Crystal and uploaded it to the Business Objects Web Interface.
    On my detail row, the last character is getting cut off regardless of the length of the text.  Even short words like "Yes" are losing the last character, and appearing as "Ye", and there is plenty of room available between the right margin.
    The column header extends out further with no issues.
    Does anyone have a solution for this?

    Hi Dean,
    Try with this:
    Go to the following registry sub key:
    HKEY_USERS\[your security profile]\Software\Crystal Decisions\10.2\Crystal Reports\Export\Pdf
    Right-click the sub key and click New > DWORD Value. Name the DWORD value "ForceLargerFonts" and set it to the value of 1.
    Regards,
    Shweta

  • How can I stop the last character of my password from being displayed?

    Sorry, I'm sure this would have been asked before, but I couldn't locate it..
    When unlocking my iPad, how can I stop it from displaying the last character of my password to everyone in the vicinity? This has got to be the fastest way to find out someone's password (just look at the screen as they type their 'secure' password!?). Having the iPad display your password letter by letter is really not acceptable when working in a non-secure environment.
    Is there a setting somewhere, or will this be addressed in a new iOS, or just ignored as a 'that's the way it is'?
    Thanks in advance,
    Andy

    AdventureBear wrote:
    Hi,
    This may have been the way it has been on iOS since 2008 (not sure about that though), however I know (based on working in the IT industry for 20 years) that nobody on this planet can successfully argue that it would be 'acceptable security practice', for me to display 'every last letter' as I type of a secure 'root' password on my screen every day when you log in... Nobody would think it acceptable to display even their LAN/Domain password on the screen in this same manner. So why is iOS different?!
    iOS on a phone (it used to be argued) doesn't need to be very secure as it is almost entirely phone numbers and email addresses that are being stored. However in recent years when the applications got better, and tablets came out, security became a much bigger issue as more and more people started using the functions of 'smart' phones to store more 'sensitive' data.
    Kind regards,
    Andy
    Are you suggesting that someone looking over your shoulder can't see the keys that you're tapping with your fingers? In the interest of security, i would never, under any circumstances, enter a password when others are around.

  • Downloading ALV to EXCEL - in some fields the last character is missing ...

    Hi,
    I am experiencing this kind of problem when downloading ALV report into Excel :-
    "You are downloading an ALV result to an EXCEL file. In some fields the last character is missing."
    For example, if MATNR is 0000234567 in display but after downloading to excel it becomes only 23456.
    I found another related forum thread : Pronlem while downloading ALV grid to excel
    I tried the suggested method to apply OSS note 1075315. However, the note cannot be implemented in the system. I am working in a ECC6 environment (SAP version 700, 701).
    Kindly please help me if you came across the similar kind of issue. Thanks much.

    Hi gkGoh8     ,
    The link thread that you just gave already provided the answer, in your field catalog you need to activate field lzero.
    1. Check FM : REUSE_ALV_GRID_DISPLAY
    2. Import Parameter tab :IT_FIELDCAT
    3. Double click SLIS_T_FIELDCAT_ALV
    4. On type group SLIS, check line 93
    Regards,
    JQC

  • How to remove a character in a file??

    I'm not getting how to remove a character from a file.Could anyone post a method to do this?Any help would be appreciable.

    Ohhh... and one more thing... unless you're really unlucky, a few "extranious trailing nulls" won't make a jot of difference to the size of the file on disk, each each file "fills" whole blocks anyway, which is 1K (I think) on both fister and *nix... unless of course we're talking "lots" of trailing-nulls, or lots-and-lots of files.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Truncating last character in a string

    I am making a dialpad. It is just for display so I am using a
    string for the numbers selected. I am trying to make a back button
    that would clear the last number added. I tried mystring.length-1
    but that doesn't seem to be doing the trick. Is there a simple way
    to truncate the last character in a string, of variable
    length??

    Here's an example
    var someStr="asdfasdf saf asdf sadfas dfs fsa asf";
    while (someStr.length) {
    someStr = someStr.substring(0,someStr.length-1)
    trace(someStr);
    }

Maybe you are looking for

  • IPhoto 9.4.1 does not solve all sync issues

    The 9.4.1 update does not solve all the sync issues. It may have fixed the duplicate Events that you can see in iTunes when syncing to an iDevice, but it has not resolved the duplicate Faces. I still have many duplicate Faces showing, even though in

  • Audigy 2 zs quest

    I am new to the Audigy card and would like to know how to record whatever is playing on my computer such as something from the internet.

  • Solaris 10 Cannot login

    Hello World: Those of you who are from the "old school" will get the salutation! In any case, I am have a problem with my Solaris 10 system. Recently, I ran patchadd for those patches that were downloaded by the Sun patch manager into /var/sadm/spool

  • Takes/Comp "dead" area at beginning of swipe

    In Logic 8, went to fix a vocal part in a track previously recorded in Logic 7. I did not have "Replace" enabled so it was recorded as a new "Take". A little startled but I did some manual diving and saw what was happening. But... Wherever I start my

  • A Challenge

    Here's a challenge for those of you running ZCM. How about a report that shows those machines with NO AV installed on them? (yes i'm being lazy - just wondered if anyone else had already written one)