Replacement of several commas in a string

Hello

Hello

I have a string similar to the following.
1, Accenture, EDS, Sun, training partner
2, United States
3.Canada,

I want to have the chain as follows as a result of the query.
1 Accenture, EDS, Sun, workout partner
2. the United States
3 Canada

Help is appreciated.

_PS

Here is the script to create the table and insert the script.
create table time
(val varchar2 (1000));

insert into time values (' ', Accenture, ed., Sun, workout partner ");
insert into time values ('United States,');
insert into time values ("Canada");
insert into time values (', Canada ');
commit;

Please provide your db version to see if the solutions of regexp_ apply too ;)

Tags: Database

Similar Questions

  • How to remove several commas in a string

    Hello friends,

    I have a string like "Myriam, pqrstu, prquste.

    Need to convert to a seperated string comma as "pqrstu, Fund, Myriam, prquste.

    I used RTRIM ('Myriam, pqrstu, Fund, prquste, ',' '), but commas between the chain is not deleted but only on the right side of the string

    Select RTRIM ('Myriam, pqrstu, Fund, prquste,', ') twice;

    I hold in a single select statement.

    Please advice.

    Thank you/Kumar

    In the query, you answered, there is still a comma at the end of the chain...

    Yes, because you wrote:

    Need to convert to a seperated string comma as "pqrstu, Fund, Myriam, prquste.

    in your original question. There is comma at the end, so my example.

    However, you already fixed it ;)

    Don't forget that my example will not work for more than 2 of the comma.
    You may need to resort to the solution of Frank, but there is a risk of a loss of performance, based on the amount of data and your hardware.

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

    )

  • 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

  • Regex to replace all occurrences of an empty string, except the last

    Hello, everyone!

    I need get to a regular expression to replace all occurrences of an empty string except the last. Right now I'm doing this with this code:
    public static void main(String[] args)
    {
        String str = "abc";
        String regex = "";
        System.out.println(str.replaceAll(regex, "-").replaceFirst("-$", "")); // -a-b-c
    }
    As you can see, to do this, I have to make two calls: one for replaceAll and another for replaceFirst to get rid of the last character. So I would like to get rid of the call to replaceFirst and have the variable of regex as being a regular expression that would be to insert the character along the chain of all but the last. I'm really not very good with regexs, so I ask your help here. The thing I work, but I think it would be more elegant with just a regex to do.

    Thank you in advance.

    Marcos

    Try this:

    String data = "abc";
    System.out.println(data.replaceAll(".", "-$0"));
    
  • Insert commas in a string

    Hello world

    I have a problem with a function that inserts commas in a string... and then I want a textfield to account for this string. The function is as follows:

            var count:Number = 0;
         var q2_Final:String;
         var tempString:String = "";
         var q2_UserInput:String;
            var q2_preCalc:Number;
            var q2_preCalc = 12345678*1000;
         q2_UserInput = String(q2_preCalc);
         
         for (var i:Number = q2_UserInput.length-1; i>=0; i--) {
              count++;
              tempString+=q2_UserInput.charAt(i);
              if ((count%3 == 0) && (i - 1 >= 0)) {
                   tempString+=",";
              }
         }
         
         for (var k:Number = tempString.length; k>=0; k--) {
         q2_Final+= tempString.charAt(k);
         }
    
            q2TextAns.text="US$ "+ q2_Final;
    

    The text which is showning the text field 'q2TextAns' when I run program is ' US$ null12, 345, 678, 000 ".

    Why I get the words "null" in front of my number? No idea on how to NOT to show the words "null".

    Thank you for your time,

    Rafa.

    because you are not initializing q2_Final.  use:

            var count:Number = 0;
         var q2_Final:String="";
         var tempString:String = "";
         var q2_UserInput:String;
            var q2_preCalc:Number;
            var q2_preCalc = 12345678*1000;
         q2_UserInput = String(q2_preCalc);
    
         for (var i:Number = q2_UserInput.length-1; i>=0; i--) {
              count++;
              tempString+=q2_UserInput.charAt(i);
              if ((count%3 == 0) && (i - 1 >= 0)) {
                   tempString+=",";
              }
         }
    
         for (var k:Number = tempString.length; k>=0; k--) {
         q2_Final+= tempString.charAt(k);
         }
    
            q2TextAns.text="US$ "+ q2_Final;
    
    
  • DRM function to replace the comma in a string

    Hello

    I'm new to the DRM. I have a requirement to replace insérent in a string with the semicolon (-). Is it all built in function to achieve.

    For example -.

    input string is s1, s2, s3

    Output string should be s1, s2, s3.

    I tried to use the ReplaceStr function. This works well for replacing any other, but for the comma, it does not work.

    Appreciate your help.

    It works for me with the formula below to do a global search of replacement that uses properties to store the string the comma (s) must withdraw and a global property to contain the decimal point itself:

    ReplaceStr (PropValue (Custom.String), (Custom.Comma) PropValue,, T)

    You've been do not add commas directly in the formula contained in the definition of the property you have? That would by way too many parameters in the function when the formula is analyzed for you would end up with something like ' DRM-25620: number of parameters for the function "ReplaceStr" invalid. " 4 expected, found 5. »

    Concerning

    Craig

  • Replace several abbreviations in a string

    Hello

    I have no solution to replace more than one abbreviation in a string at a time.

    I have a table has with a "name" attribute, which contains some abbreviations e.g. 'article no. s. p.'.
    I have a table with abbreviations b with the columns 'abbreviation' and 'replace_string' e. g.
    don't. | number
    s. | section
    p. | page

    Now, I want to replace all abbreviations in 'name' with the good replace_string e. g.
    "article no. p. s."-> "page section number section.

    Can someone give me a clue how to proceed?

    Kind regards
    Detlef

    You must set these columns as measures:

    SCOTT@soti_10> desc names
     Name
     -------------------------------------------------------------------------------
     NAME
     ID
     MONTH                                                                                                          
    
    SCOTT@soti_10> select * from names;
    
    NAME                                                                 ID MONTH
    ------------------------------------------------------------ ---------- ----------
    qwe DW ff DB hhh                                                      1 22.01.2009
    qwe EEE ff DB hhh                                                    33 01.01.2008
    
    SCOTT@soti_10> with Iterations as (
      2    select rn, n, id, month
      3    from names n, abbreviations a
      4    where instr(n.name, a.abbreviation) > 0
      5    model
      6      partition by (n.name)
      7      dimension by (row_number() over (partition by n.name order by n.name) rn)
      8      measures (n.name n, a.abbreviation, a.replace_string,
      9                n.id id, n.month month)
     10      rules (
     11        n[ANY] ORDER BY rn DESC = REPLACE(
     12                                    PRESENTV(n[cv() + 1], n[cv() + 1], n[cv()]),
     13                                    abbreviation[cv()],
     14                                    replace_string[cv()]
     15                                  )
     16      )
     17  )
     18  select n, id, month
     19  from iterations
     20  where rn = 1
     21  ;
    
    N                                                                    ID MONTH
    ------------------------------------------------------------ ---------- ----------
    qwe Data Warehouse ff Database hhh                                    1 22.01.2009
    qwe KKKK ff Database hhh                                             33 01.01.2008
    

    Kind regards
    Dima

  • Replace the free-standing characters in String

    In Oracle 10.2, I want to convert the string '1 2 3 4 5 6 def abc' to 'abc def '.

    Here is the code:

    1 with t as (select '1 2 3 4 5 6 def abc' double val)
    2 * Select regexp_replace (val, ' (\s[0-9]\s)+ ',' ') t outval)
    SQL > /.

    OUTVAL
    ---
    2 4 6 dembront

    It seems that the REGEXP_REPLACE performed only one iteration of the replacement. Is there a way to get the output string 'abc def' without going through several iterations?

    Hello

    Welcome to the forum!

    Here's one way:

    SELECT     REGEXP_REPLACE ( val
                     , '((^|\s+)[0-9])+(\s|$)'
                     , '\3'
                     )     AS outval
    FROM    t
    ;
    

    The problem with your initial request was that space after a freestanding figure can count as a space before another freestanding figure, but the same character cannot be used to satisfy two different matches.
    The query above does not replace undividual
    groups of 3 characters "\s[0-9]\s"; It replaces a variable number (1 or more) of
    ] "groups of 2 characters, but only when the last of them is followed by an another \'s." (Acutally, I modified the problem a bit to account for several space characters before or after each free-standing figure and also to eliminate the freestanding numbers at the beginning or end of the val.) If you don't want these changes, it is easy to modify the above query).

  • TDMS replace specific fields with the new string data

    Hello

    Wonder if someone could advise a more easy, more clean solution or I may end up making a big mess on my diagram!

    I use DaqmxConfigureLogging.vi to write data in the .tdms and this file everything works. Unfortunately, this vi affects physical names such as Dev1/ai0 channel names in Journal of root and group of tdms files.

    I would like to read individual fields where they are written and replace them with the names of channel. The location of these channel names is fixed on the tdms file.  However, I noticed using file i/o functions, such as file open/close/set position could not work, because these files do not seem to recognize the .tdms file. And it is not all fields tdms functions you want the value of the positions on sheets of root/channel files tdms and read fields desired as string data.

    Any suggestions? I can miss something quite simple!

    crossrulz wrote:

    k waris wrote:

    "In fact, it uses some names you give the channels and groups.

    I use Dev1 / ai0:15 connect all 16 channels. Unfortunately if using 'name to assign' entry will not do the job in my case!

    Of course, it will be.  Use a loop FOR with DAQmx channel create to create each channel and give them a name.

    Just to clarify what I meant here...

  • Remove all commas in a string

    I have a company name which can contain commas in one or more positions. I need to replace the comma with a space.

    Example:

    DOM, s travel and Dom, s Express

    Need to read

    S travel and DOM. DOM s Express

    Thank you

    Paul

    > I need to replace the comma with a space.

  • Replacement of several carriage return

    Hi all, a query returns the string as [] [] [] [] [] [] [] [] BBB BBB AAA AAA. I have to replace four consecutive cart with a semicolon returns and not return the two consecutive transport. I tried
    Replace (String, Chr (13) |) Chr (13) | Chr (13) | Chr (13), ';') but it has no effect. Any help would be appreciated.
    TIA

    Try:

    replace(STRING,chr(13)||chr(10)||chr(13)||chr(10),';')
    

    It is likely that you have Windows line break characters (Chr (13) |) Chr (10) pairs) instead of Unix line break characters (just chr (13))

  • How to make replace() for each symbol in the string instead of the first meeting only?

    Hello!

    This is my simple test script:

    var str = ' re | PLA | ce »;

    var strRep str.toString () = replace (' | ', '-');

    Alert (strRep);

    I'd get a re-pla-this result string.

    But I didn't get my only first symbol replaced:

    replace.png

    Can you advise me please, how to get all the symbols replaced?

    Thank you!

    Thank you very much, Xavier!

    Just for reference, this line will work perfectly:

    Alert (str.toString () replace (new RegExp ("|", "g"), '-'));

  • Extract values separated by commas in xquery string

    Hello

    We get a string with values separated by comma Ex: a, b, c.

    Our requirement is to mark the string and transform values to an XML using xquery.

    I'm new to xquery. Can someone help me on this please.

    Thank you
    Chauvin

    Hi Jacky,.

    You can use the function "mark".
    For example:

    let $str := "a,b,c"
    return 
    {
     for $i in tokenize($str,",")
     return     { $i }
    }
    
    

    will return:

    
       a
       b
       c
    
    
  • How can I insert commas in a string to a number?

    Here's the process I use to

    generates a numeric string in an Acrobat form:

    var A = this.getField("fieldname").value * 1000000000
    var B = this.getField("fieldname").value * 1000000000
    var C = this.getField("fieldname").value * 1000000000
    var D = this.getField("fieldname").value * 1000000000
    var E = this.getField("fieldname").value * 1000000000
    var F = this.getField("fieldname").value * 1000000
    var G = this.getField("fieldname").value * 1000000
    var H = this.getField("fieldname").value * 1000000
    var I = this.getField("fieldname").value * 1000000
    var J = this.getField("fieldname").value * 1000000
    var K = this.getField("fieldname").value * 1000
    var L = this.getField("fieldname").value * 1000
    var M = this.getField("fieldname").value * 1000
    var N = this.getField("fieldname").value * 1000
    var O = this.getField("fieldname").value * 1000
    var str = A - B - C - D - E + F - G - H - I - J + K - L - M - N - O

    For example, the resulting string is: How can I insert commas so the chain will read from 237036054000: 237,036,054,000?

    The number string is not always the same length so I need to add commas to the right. For example, the number may be: 7,234,887,000 or 124,345,000. The only constant is that the numbers will end in "000" as there are no hundreds in the sequence, I work with.

    I have to add commas to the strobila, so I can break the string up in the same type of components that I started with. I already part, but I need to insert commas as a separator for the second half of work.

    Thanks much for any help you can offer.

    Steve

    What is a custom calculation script? If so, do you have to checked to make sure that the field calculation order is correct?

Maybe you are looking for

  • The "Remember passwords for sites" setting maintains have turned off whenever I close Firefox.

    After the ESR 38.0.1 (and later upgrade to 38.0.5) the "Remember passwords for sites" setting is disabled after the closure of a browsing session. If I like the beginning of a new session, it works exactly as expected, but the setting never persists

  • Satellite T130 - 11 H - NO Audio output device is installed

    I brought this new * Toshiba T130 - 11 H Satellite * (Windows7 / x 64) last week and at first, it was fine... Although I now have the speaker icon formidable with a RED CROSS in the lower right of the screen!It's become such a pain now - ive never ha

  • Satellite A305-S6872 - lack of Vista recovery DVDs

    I buy Satellite A305-S6872 months back now, I want to recover my laptop back to the factory setting. I have a virus problem... But when I have I bought didn't find any CD/DVD recovery in the box. Computer laptop hasn t any recovery partition...There

  • Import the Visio drawing in Labview

    Hello I do not use standard screws to display and control. Instead I created a picture or drawing of the application who will use Labview. It's a drawing of a part of the plane that have installed controls and sensors. I would use this drawing I crea

  • APPROVE THE POST

    APPROVE MY POST PLEASE :( PLEASE PLEASE THANK YOU