Replace every third comma with |

Hi all

My requirement is like this:
In a column i need to replace every third comma(,) with || symbol.

eg:
1,Animesh,1234,2,Tripathi,4321,3,Oracle,2345.....(and so on)

Desired output:
1,Animesh,1234||2,Tripathi,4321||3,Oracle,2345....
Please help me.
-
Concerning
Animesh

Published by: Animesh Tripathi on December 11, 2012 02:22

Hi Anne,.

Try using the regex.
Try the code below.

SET SERVEROUTPUT ON
DECLARE
v_file VARCHAR2(100) :=  '1,Animesh,1234,2,Tripathi,4321,3,Oracle,2345';
  v_file1 VARCHAR2(100);
BEGIN
  SELECT REGEXP_REPLACE (v_file, '(([^,]*,){2}[^,]*)(,)', '\1||')
  INTO v_file1
  FROM DUAL;
  DBMS_OUTPUT.PUT_LINE(v_file1);
END;

I found above solution of one of the thread.

You can find some details on regex_replace below given link.
http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions130.htm

Kind regards
Jitendra

Tags: Database

Similar Questions

  • Replace the comma with | in a column

    Hi all

    My requirement is like this:
    In a column, I need to replace every third comma with | symbol.
     
    eg:
    1,Animesh,1234,2,Tripathi,4321,3,Oracle,2345.....(and so on)
     
    Desired output:
    1,Animesh,1234||2,Tripathi,4321||3,Oracle,2345....
    Please help me.
    -
    Concerning
    Animesh

    Hello

    Here's one way:

    WITH mydata AS
    (
       SELECT '1,Animesh,1234,2,Tripathi,4321,3,Oracle,2345' txt FROM DUAL
    )
    SELECT REGEXP_REPLACE (txt, '(([^,]*,){2}[^,]*)(,)', '\1||') txt
      FROM mydata;
    
    TXT
    ----------------------------------------------
    1,Animesh,1234||2,Tripathi,4321||3,Oracle,2345
    

    Kind regards.
    Al

    Published by: Alberto Faenza December 11, 2012 11:51
    Simplified regular expression

  • Replace the comma with space - we can do it without REGEXP?

    11 GR 2 DB.

    Can you replace comma with a space without using REGEXP?
    Sample String: 'To,Replace,,Comma(s),,,,with space,,,'
    Expected output:'To Replace Comma(s) with space '

    884476 wrote:
    11 GR 2 DB.

    Can you replace comma with a space without using REGEXP?

    You could do it with REPLACE nested...

    select    replace(
                replace(
                  replace(
                      'To,Replace,,Comma(s),,,,with space,,,',',','#$'
                         ),
                      '$#',''
                       ),
                     '#$',' '
                     ) str
    from dual;
    
    STR
    -------------------------------
    To Replace Comma(s) with space 
    
  • Replace the comma with a period in a text layer expression

    Hello!

    I need to make a simple counter to 0 billion, so I found this expression that works perfectly:

    Start code

    startTime = 0; seconds

    endTime = 5; seconds

    beginCount = 0;

    endCount = 9700698977;

    hasCommas = true;

    function addCommas (s) {}

    If (s.length < = 3)

    return s;

    on the other

    Return s.substring (0, 3) + ', ' + addCommas (s.substring (3, s.length));

    }

    function reverse (s) {}

    newStr = "";

    for (i = s.length - 1; i > = 0; i--)

    newStr += s.charAt (i)

    return newStr;

    }

    Val = Math.round (linear (time, startTime, endTime, beginCount, endCount));

    If (hasCommas)

    reverse (addCommas (reverse (val + "")))

    on the other

    Val

    end of the code

    The problem is that I need to change the commas with pins to look like 9.700.698.977, someone knows how to do?

    Just change this line:

    Return s.substring (0, 3) + ', ' + addCommas (s.substring (3, s.length));

    to do this:

    Return s.substring (0, 3) + '. ' + addCommas (s.substring (3, s.length));

    Dan

  • I replaced my Firefox3.6 with version 4 is not working on my computer. How can I reinstall Firefox 3.6?

    I've replaced Firefox 3.6 with version 4 that is not on my computer. How can I reinstall Firefox 3.6?

    Firefox 4 requires at least OS X 10.5 and an Intel Mac. There is a third part of Firefox 4 version that works under OS X 10.4/10.5 and PPC Macs, for details, see http://www.floodgap.com/software/tenfourfox

    If you prefer, you can get the latest version of Firefox 3.6 http://www.mozilla.com/en-US/firefox/all-older.html

  • Printer to skip every third line

    My Deskjet 2050j skip every third or fifth line based on the document that I print. I've tried all sorts of cleaning of the printer have options, I refilled the cartridge, tried printing in three different computers and still have the same problem. Then I tried to print a horizontal page with the same text, I had no problem, then tried to print a drawing in black and white, I did and it was no problem. I only get this problem when printing text in a page in a vertical way.

    Info:
    Model: Deskjet 2050 all-in-One J510a

    Firmwre version: SLM2FN1006BR

    the printer software version: 022.050.231.000
    driver version: 04.43.07.853

    This is due to a problem of electric contact between yout printer and cartridge
    Try cleaning the contacts of the cartridge with a lint free tissue. (A folded dollar bill works well).

  • 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 '.

    )

  • Is it possible to replace the hard drive with an SSD? or would it be too expensive?

    Is it possible to replace the hard drive with an SSD?

    or would it be too expensive?

    Yes.  There are several alternatives.  I found a way relatively inexpensive, using a map of mSATA (very small SSD) and an adapter to connect it to the connector IDE 44 pin internal of my PowerBook.  It works very well.  Rather than repeat what I posted previously, you can watch these two topics (which also has good info, other users)

    Re: This win to install a SSD drive in a PowerBook G4?

    Re: SSDS  (my post is halfway - "this is how I did with my trusty Pismo...) »)

    FYI - I have used the adapter is even cheaper now

    https://www.Amazon.com/GP/product/B009BA8V4M

  • Given to replace my current iphone with a 6s - a trip that I can disable the use of boxes and use a unique sim card data for emails

    Given to replace my iphone today with a 6s - a trip that I can disable the use of boxes and use a sim card only data for email & web.

    If you go to settings > Mobile and less ' use of mobile data for: "turn off all except Safari and Mail

  • Replace old hard drive with an SSD.  Nowsome keys on the keyboard no longer works.  Ex 'e' and 'b' keys no longer work?  Any idea what could take place in the disc replacement?

    Replace old hard drive with an SSD.  Now some of the keys on the keyboard stopped working.  Ex 'e' and 'b' keys no longer work?  Any idea what could take place in the disc replacement?

    Probably nothing, it's probably a fluke. Try resetting the SMC and the PRAM by iMac Intel SCM and reset the PRAM. If this does not work, try a USB keyboard to test, if it works then your original keyboard has failed and must be replaced.

  • laptop HP pavilion touch 14: replaced defective hard drive with pre installed OS on new HDD - device not found Boot (3F0)

    Hey guys,.

    I have a pc hp pavilion touch laptop 14, which has been having a defective hard disk that the operating system was not start and the system test indicated that the hard drive contained errors.

    I replaced the hard drive with a new one and before installing the hard drive I formatted with a win installation 8.1. I thought the laptop would just start normally to win8, but gave me a screen saying:

    boot device not found please install an operating system on drive hard drive (3f0)

    The hard drive is new and I did not not how its gives me this error!

    In addition, this laptop does not seem to boot from a cd to format!

    Any ideas?

    Thank you
    Karl

    Hey BHK6,

    I found out what was wrong! It was so simple!

    I just need to make the boot inherited from the bios, like that he started directly from the hard drive and does not need of any software pre installed HP to start.

    Thanks for your help anyway

    Karl

  • I just replaced my MB Pro with a MB Air. Air has less memory and will not support a full restore of files and the saved data. How to do a partial restore

    I just replaced my MB Pro with a MB Air. Air has less memory and will not support a full restore of files and the saved data. How to do a partial restore

    Do you still have the MBP? If so you can manually copy and paste the files you need.

    If you do not have the pro more, you need to buy a USB key and plug it into the MBA... use it as a target. Once you have a system file of the previous laptop again, you have to manually choose what to copy across.

  • Re: Tecra A9 - 11M - replace the HARD drive with a larger

    I have a Tecra A9 - 11 M with Windows XP Professional installed. I would like to replace the hard drive with a larger drive and install Windows 7 Professional.

    Any suggestions on recommended records say 500 MB?

    Difficulties to install Windows 7 on this model?

    Hey,.

    > Any suggestions on recommended records say 500 MB?
    I assume you mean 500 GB and not 500MB, right? ;)

    Well, the Tecra A9 already supports SATA interface and there is no limit of capacity on SATA interface, so you can install a 500 GB HARD drive or more (750 GB, etc.). Just make sure that it s 2.5 SATA HDD.

    You can choose each brand of HARD drive because each model will not work. You can buy a Toshiba HDD, Western Digital HARD drive or another. No problem ;)

  • Qosmio X 500 - 10W - can I replace the HARD drive with another?

    Hello

    I have a Qosmio X 500 - 10W with two drive HARD Toshiba MK5055GSX 500 GB 5400 RPM 8 MB? SATA II but is one of the hs so I'm wondering if I can be replaced by a more powerful style, drive HARD 750 GB 7200 RPM / min 16 MB Toshiba courses?

    Thank you

    Hey,.

    Your question is a bit hard to understand, but I think you want to replace the HARD drive with another (faster) model, right?

    Well, that s no problem. 7200 RPM hard drives works, they are a little stronger, but they're faster so if you need more performance without problem.
    750 GB or more are also no problem because the SATA interface is not the limited capacity. Theoretically 1 TB or more should also work.

    Anyway, you can buy the 750Go you mentioned that it will work. :)
    ?

  • I replace my airport express with the new model. Flashing orange. It works, but cannot configure security. Tried to reset via the reset button.

    I replace my airport express with the new model. Flashing orange. It works, but cannot configure security. Tried to reset via the reset button. Tried unplugging and tried unplugging the modem. I would like to fix.

    Modem... doing and... model number you have?

    What operating system do you use on your Mac, or you are using an iPhone or iPad set things up... or a PC?

Maybe you are looking for