Replace multiple characters in a string

Hi, I have some string fields that contain special characters such as ô and û and I want to replace them with ō and ū, and their upper case equivalents as well. How do I write a single formula that would find any of these characters in a string and replace them?
Thanks,
Will

replace(replace(replace(replace(x,'ô','ō'),'û','ū'),'Ô','Ö'),'Û','Ü');
where x is the string field.  I suggest using the unicodes rather than the actual character.  I do not think that I have the correct uppercase characters.  Please ensure that they are correct in your formula.

Similar Messages

  • Replace multiple characters to single character

    Hi friends,
    I would like to replace multiple characters in a string to a single character. The character may be a pipe (|) or a tilde (~).
    For example "|||asdf||123|xyz||" should be changed to "asdf|123|xyz".
    I use Oracle 11g2.
    Thanks in advance!

    Without regexp
    with testdata as (
        select '||asdf||||123|xyz|' str from dual union all
        select 'asdf|123|||||||xyz||||' from dual union all
        select '||||||asdf|||123||||||xyz||||||' from dual
    select
    trim (both '|' from
        replace (
            replace (
                replace (str,'|','|'||chr(0))
                ,chr(0)||'|'
            ,chr(0)
    ) str
    from testdata
    STR
    "asdf|123|xyz"
    "asdf|123|xyz"
    "asdf|123|xyz"
    with regexp
    with testdata as (
        select '||asdf||||123|xyz|' str from dual union all
        select 'asdf|123|||||||xyz||||' from dual union all
        select '||||||asdf|||123||||||xyz||||||' from dual
    select
    trim (both '|' from
        regexp_replace (
            str
            ,'\|+'
            ,'|'
    ) str
    from testdata
    STR
    "asdf|123|xyz"
    "asdf|123|xyz"
    "asdf|123|xyz"
    Message was edited by: chris227 regexp added

  • Replace multiple whitespaces in a string with single one

    Hi,
    I'm using Oracle 9.2.0 and I have a query on string manipulation.
    Can I replace multiple whitespaces within a string with single one. I tried with regexp_replace function but it is not supporting Oracle 9i.
    Can someone help me out?
    Regards,
    Pramod

    Just playing around:
    WITH
         Strings
    AS
          SELECT 'Can  I   replace      multiple  whitespaces   within    a     string    with single one' Text FROM Dual
    SELECT
         REPLACE
          REPLACE
           XMLAGG
            XMLElement
             "A",
             SubStr(Text, Level, 1)
           '</A>'
          '<A>'
         ) Text
    FROM
         Strings
    WHERE
         NOT
              Level > 1
          AND     SubStr(Text, Level, 1)          = ' '
          AND     SubStr(Text, Level - 1, 1)     = ' '
    CONNECT BY
         Level <= LENGTH(Text);

  • Need help in replacing special characters in a string

    Hi,
    please let me know the best way to replace all the special characters in a string with space.
    other than alphabets and numbers
    with regards.
    sumanth.

    please let me know the best way to replace all the special characters in a string with space.
    other than alphabets and numbers
    >
    Sumanth Nag Kristam wrote:
    > actually i need to replace hexa decimal char 0X1A in a string.... that is 'substitue' as per the chart
    > any pointers....
    >
    > chk the link for the ASCII codes
    > http://www.techonthenet.com/ascii/chart.php
    But in Hexa decimal value there is no special characters?

  • Regular expressions-how to replace [ and ] characters from a string

    Hi,
    my input String is "sdf938 [98033]". Now from this given string, i would like to replace the characters occurring within square brackets to empty string, including the square brackets too.
    my output String needs to be "sdf938" in this case.. How should I do it using regular expressions? I tried several possible combinations but didn't get the expected results.

    "\\s*\\[[^\\]]+\\]"

  • Regex replacing multiple characters in string.

    I have been working through the Java regex tutorial and tried to modify one of the programs for my own use. Basically, I want to take a string and convert the chatracters A to T, T to A, C to G and G-C.
    I produced the rather crude program below, but of course it doesn't work. A could be converted to T and back again before the program terminates.
    I know that the code to do this correctly is probably quite complex, so could anyone point me in the direction of a tutorial which will help me to do this?
    This aside, I take it that if I am looking for multiple matches of characters which won't give the problem already indicated above, my code is too bloated anyway. Say, for example, instead of wanting to replace A to T, T to A, C to G and G-C, I wanted to replace dog-cat, horse-donkey - lion, tiger , cat-mouse. My code will work for this, but I am sure that it could be compressed a lot. Surely I would not need all the lines of code to do this?
    Thanks for any help,
    Tim
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    import java.io.*;  // needed for BufferedReader, InputStreamReader, etc.
        /** A Java program that demonstrates console based input and output. */
         class dna {
            // Create a single shared BufferedReader for keyboard input
            private static BufferedReader stdin =
                new BufferedReader( new InputStreamReader( System.in ) );
            // Program execution starts here
            public static void main ( String [] args ) throws IOException
                // Prompt the user
                System.out.print( "Type your DNA sequence: " );
                // Read a line of text from the user.
                String DNA = stdin.readLine();
                DNA = DNA.toUpperCase();
                String DNA2 = DNA;
                //calculate reverse complement
                Pattern A = Pattern.compile("A");
                Pattern T = Pattern.compile("T");
                Pattern C = Pattern.compile("C");
                Pattern G = Pattern.compile("G");
                Matcher AA = A.matcher(DNA);
                DNA = AA.replaceAll("T");
                Matcher TT = T.matcher(DNA);
                DNA = TT.replaceAll("A");
                Matcher CC = C.matcher(DNA);
                DNA = CC.replaceAll("G");
                Matcher GG = G.matcher(DNA);
                DNA = GG.replaceAll("C");
                // Display the input back to the user.
                System.out.println( "DNA input             : " + DNA2);
                System.out.println ("Complementary sequence: " + DNA);
        }

    TimM wrote:
    Thanks a lot!!! Can't believe you managed all that with so few lines of code.You're welcome.
    Must be great to know what you are doing :-)
    Thanks again,
    TimAfter being a bit more familiarised with the methods of String, you'll be able to do this in no time, I'm sure!

  • Replace Special Characters in a String

    Let's say someone copies the folowing list and pastes it into a Javascript prompt box:
    302304
    305678
    245675
    How do I manipulate the string so it reads:
    302304 305678 245675
    In other words, how do I replace the manual line breaks in a string with spaces?
    Thanks!

    \r and \n are both \s characters.
    This is functionally equivalent to what you have...
    stringName = stringName.replace(/\s/g,' ');
    I highly recommend browsing this website (lots of useful info there):
    http://www.regular-expressions.info/
    Harbs

  • Replacing Unicode characters in a String

    I have a text as a String and in this text which is foreign language appears sometimes characters in Unicode format as &amp;#246; or &amp;#214;
    The question is, how can I convert this String so these Unicode characters would become readable characters.
    Thank you for any lead...

    :-) Interesting - twice in 10 minutes I'm recommending the use of Elliott Hughes' class. See http://elliotth.blogspot.com/2004/07/java-implementation-of-rubys-gsub.html .
    You just have to write a regular expression to match the terms ( "&#(\\\d+)"), extract the number as a string (group(1)) then use the Integer.parseInt(the numeric string) and cast to a char.
    Edited by: sabre150 on Feb 9, 2012 9:53 AM
    This is an example I wrote a couple of years ago (and published on the old Sun site forums) that does pretty much exactly what you need
    import e.util.Rewriter;
    public class Sabre20090919
        public static void main(String[] args) throws Exception
            String title = "& #26412;& #26399;& #28136;& #21033;\n" +
                    "& #22522;& #26412;& #27599;& #32929;& #30408;& #39192;\n" +
                    "& #32380;& #32396;& #29151;& #26989;& #21934;& #20301;& #28136;& #21033;\n" +
                    "& #26371;& #35336;& #21407;& #21063;& #35722;& #21205;& #32047;& #31309;& #24433;& #38911;& #25976;\n" +
                    "& #26222;& #36890;& #32929;& #27599;& #32929;& #30408;& #39192;\n" +
                    "& #31232;& #37323;& #27599;& #32929;& #30408;& #39192;\n";
            Rewriter rewriter = new Rewriter("&\\s*#(\\d+);")
                @Override
                public String replacement()
                    return Character.toString((char) Integer.parseInt(group(1)));
            title = rewriter.rewrite(title);
            System.out.println(title);
            System.out.print("Unicode :\"");
            for (char ch : title.toCharArray())
                System.out.printf("\\u%04x", (int) ch);
            System.out.println("\"");
            byte[] asBytes = title.getBytes("big5");
            for (byte b : asBytes)
                System.out.printf("%02x ", (int) (b & 0xff));
            System.out.println();
    }The rest is just a test harness.
    Edited by: sabre150 on Feb 9, 2012 10:02 AM
    Removed redundant code

  • How to replace escape characters in a string ?

    Hi All,
    In my application I came across a problem where I want to replace a substring (contains escape characters also) with another string. The below shown code will replicate my problem :
    public class StringSearchAndReplace {
      public static void main(String args[])   {
        String stmt = " \\pntext\\bullet\\tab The question as to ";
        String newStmt = stmt.replaceAll("\\bullet\\tab",  "B");
        System.out.println("BEFORE: " + stmt + "\n");
        System.out.println("AFTER: " + newStmt);
    }Here I want to replace "\\bullet\\tab" with "B". I am unable to move further. Please help/suggest me in this regard.
    Its urgent.
    Thanks in advance.

    Satyaprasad_Mylavarapu wrote:
    Hi All,
    In my application I came across a problem where I want to replace a substring (contains escape characters also) with another string. The below shown code will replicate my problem :
    public class StringSearchAndReplace {
    public static void main(String args[])   {
    String stmt = " \\pntext\\bullet\\tab The question as to ";
    String newStmt = stmt.replaceAll("\\bullet\\tab",  "B");
    System.out.println("BEFORE: " + stmt + "\n");
    System.out.println("AFTER: " + newStmt);
    }Here I want to replace "\\bullet\\tab" with "B". I am unable to move further. Please help/suggest me in this regard.
    Its urgent.
    Thanks in advance.If the String you're trying to replace contains a slash you need four slashes (double it for java, then again because String.replaceAll takes a regular expression)
    So I think what you're looking for is:
    String newStmt = stmt.replaceAll("\\\\bullet\\\\tab",  "B");I haven't tested that though.

  • Replace Special Characters in a string + XQUERY

    Hi All,
    I am using the following replace function to replace the special characters in my XQUERY.
    *replace($string1, '[&"-*;-`!|:,¿/{}@#$%^*~()_+-]', ' ')*
    Fortunately it is replacing all the special characters. But the only problem here is it is even replacing capitol letters in to spaces, which I don't want.
    Please help me out!!

    Hi
    <<< What did u change >?> I dont see any change with the Regex ?  >>
    if you observe in the modified function, he just removed (*) inside the replace funtion.
    Thanks
    Shankar AUNV

  • PHP: automatically replace alphanumeric characters in a string

    Quick question:
    How do I program a PHP script to replace all non-alphanumeric
    charters within a string, with underscores?

    .oO(AngryCloud)
    >Yes, this does help, although it is only alphabetic.
    >
    >Will changing the line to this make it alphanumeric?:
    >
    >$new_string = preg_replace("/[^a-zA-Z0-9]/", "_",
    $string);
    Did you try it? ;-)
    You could also use this shorter pattern:
    /[^a-z\d]/i
    Should be the same (\d matches decimals and the /i modifier
    makes the
    entire thing case-insensitive).
    Micha

  • A clever way of replacing some characters in a string

    I have a string passed between methods in classes. Due to a face that I don't have all data ready when the string is constructed at the first place. I need to a few of sections in the string before I can use it. I am wondering any clever way to carry out this task.
    Here is a sample of such string:
    <web site name>/book.html?bookid=<book id data + series data>&language=<language data>
    where <web site name> <series data> from the first method and <book id data> and <language data> from the second method.

    One way would be to pass a String array that contains the sections that need to have other pieces inserted between them:
    [ "/book.html?bookid=" , "&language=" ]That's not a very flexible solution though, a better way would be to pass a Map<String, String> around, which holds the bookid, language, etc. Strings as keys, and lets the other methods map them to <book id data + series data>, <language data>, etc. values. Then when they're all populated, construct the final url from those values.
    That way if the params of the string change, it's easier to change the methods that populate the values.

  • Replace characters in a string

    Hi,
    I need to replace all occurrences of control characters except space,newline,tabs in a string . I can give a replace statement for each of these characters but I want to avoid this by making use of regular expressions. Can anyone help me in this regard.
    I tried using the following replace statements with regular expression, but i am not getting the required results:
    replace all occurrences of REGEX '[[:cntrl:]]' in lv_char with space replacement count lv_count_r.
    ---> this replaces even the spaces
    replace all occurrences of REGEX '[[:cntrl:]][^[:space:]]' in lv_char with space replacement count lv_count_r.
    --> this replaced even some alpha numeric characters
    Thanks and Regards,
    Shankar

    is there anyway to do this without using regular
    expressions.. regular expressions are the last
    solution for me..Remember that you can never really replace the characters of a String. Strings are immutable. Once created they cannot change.

  • Replace multiple space characters with a single space

    Hi,
    Oracle 11g R2.
    Looking for a way to replace multiple space characters in a row with a single space. For example, the text "abc abc" should look like "abc abc". I tried toying with replace, but it only works for the case of 2 spaces. Need a solution for the cases where there could be 2 or more spaces.
    select replace(column1, chr(32)||chr(32), chr(32)) from tablea

    Hi,
    If you had to do this without regular expressions, you could use:
    SELECT  REPLACE ( REPLACE ( REPLACE (str, ' ', '~ ')
                     , ' ~'
              , '~ '
              )     AS new_str
    FROM    table_x;assuming there is some sub-string (I used '~' above) that never occurs right next to a space.
    However, unless you're uisng Oracle 9 (or earlier, which you're not doing) you don't have to do this without regular expressions. As you can see, the way Solomon showed is much simpler.

  • Replacing multiple new line characters

    how to replace multiple new line characters in a line.
    Suppose for example my line contains Example1#####Example2##Example3###Example4,
    then the output should be Example1#Example2#Example3#Example4.

    Hi Sid,
    You Can try this code
    DATA: ld_string TYPE string,
          ld_string1 TYPE string,
          ld_string2 TYPE string,
          ld_string3 TYPE string.
    ld_string = 'Example1#####Example2##Example3###Example4'.
    REPLACE ALL OCCURRENCES OF '######' in ld_string with '#'.
    REPLACE ALL OCCURRENCES OF '####' in ld_string with '#'.
    REPLACE ALL OCCURRENCES OF '###' in ld_string with '#'.
    REPLACE ALL OCCURRENCES OF '##' in ld_string with '#'.
    write:/1 ld_string.
    Regards
    Pavan

Maybe you are looking for

  • Getting schema validation working in Eclipse with Coherence 3.7.1.0

    Just wondered if anyone had got schema validation to work in Eclipse (3.5 - Galileo) for Coherence 3.7.1.0? The Coherence developer docs show that you should add sections like this: <pof-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xm

  • Unique constraint violation while updating a non PK column

    Hi, I seem to have found this strange error. What I try to do is bulk fetch a cursor in some table arrays. with limit of 1000 Then using a forall and a save exceptions at the end I update a table with the values inside one of the table arrays. The co

  • Books and Documentation on Webdynpro for Java

    Hi,    I'am planning to start developing Webdynpro for Java applicatios.I know only Core java and iam not familiar with J2EE.I need some help on this.Any books on webdynpro for java basics and any documentation avail and prerequisite befor going to s

  • "http request error" - SQL call sometimes works, sometimes doesn't

    Hello everyone, A bit of a random question, maybe someone has an idea... I have a flex app that queries data from a mySQL service via http service. Overall, things work great! The queries are quick to return a result and without issues. But, when I v

  • Setting the global Font color for an application

    Hi, Can anyone tell me how I can set the default font colour for an application. I understand it involves using the UIManager class to somehow get/set the defaults but im stumped after that. Thanks in advance