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.

Similar Messages

  • Replacing multiple spaces with a single space

    Hi friends,
    I have a string. It can have zero/one/multiple spaces. I want to make the multiple spaces to single space.
    Here are the cases:
    1. ' a b c d efg h' should be changed to 'a b c d e f g h'
    2. ' a b c d e f g h ' should be changed to 'a b c d e f g h'
    3. 'a b c d e f g h' should not be changed
    4. 'abcdefgh' should not be changed
    Both REPLACE and TRANSLATE do not help. I don't want to go for LOOP logic. Please help me to get it in SQL query.
    Thanks in advance!

    Hi,
    964559 wrote:
    Hi friends,
    I have a string. It can have zero/one/multiple spaces. I want to make the multiple spaces to single space.
    Here are the cases:
    1. ' a b c d efg h' should be changed to 'a b c d e f g h'One solution is to post your string on this site, and then copy it back again. (See below for a more serious solution .)
    This site is doing exactly what you want the function to do: it replaces multiple consecutive spaces with a single space. As a result, it's hard to see what you mean.
    To preserve spacing on this site, type these 6 characters
    \(small letters only, inside curly brackets) before and after each section where you want spacing preserved.
    2. ' a b c d e f g h ' should be changed to 'a b c d e f g h'
    3. 'a b c d e f g h' should not be changed
    4. 'abcdefgh' should not be changed
    Both REPLACE and TRANSLATE do not help. I don't want to go for LOOP logic. Please help me to get it in SQL query.
    Thanks in advance!Regular expressions make this easy:SELECT TRIM ( REGEXP_REPLACE ( str
    , ' +'
    ) AS compressed_str
    FROM table_x;
    You can use nested REPLACE calls to get the same results, but it's messy.
    Edited by: Frank Kulash on Feb 5, 2013 10:18 AM
    Added TRIM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Multiple vendor payments with a single u201CYOURSELFu201D cheque

    Hi,
    How do we handle multiple vendor payments with a single u201CYOURSELFu201D cheque, drawn in favor of the paying banker? OR NEFT transfers in SAP.
    Thanks,
    M. Senthil

    Hi
    First things first:
    1. You want to create a single payment document for multiple vendors.  In such a case, you will not be able to use F110. You need to use F-53 or F-f8 in such a case. In the all the vendor masters, maintain the alternative payee with Description as "YOURSELF". There after, if you are using F-53, use FBZ5 to print the cheque in the name of alternative payee.
    2. if you are using F110, multiple payment documents will be created for different vendors. In FBZP Config, you can assign the Payment Advise Form in the Payment Method Step in FBZP Config
    Regards
    Sanil

  • How do I replace multiple consecutive spaces with a single space?

    I need to convert any occurrence of multiple consecutive spaces in a string to a single space. How do I create the regex pattern to do that?

    r9973 wrote:
    Sorry, more like: String test = "Some        Text       Here"Want to convert to String test = "Some Text Here"
    Post the code that you used to test the regex. I just tried it and it worked fine for me. All you need to do is apply the regex replaceall to your string variable that holds the string
    String test = "Some        Text       Here";
    test = test.replaceAll(" +", " ");
    System.out.println(test);And thats it.

  • Multiple iTunes accounts with a single ipod?

    I just bought my daughter a new ipod Touch.  Will she be able to download music into the ipod from both my itunes account and from her mom's seperate itunes account, or will her ipod only be able to be associated with a single itunes account?  Thanks.

    You can use multiple iTunes accounts on one iPod.  Just note that you can only sync with one iTunes library/computer.  However, yu can manage music among different computers. See:
    Using iPhone, iPad, or iPod with multiple computers

  • Is it possible to maintain multiple payment formats with a single Program

    Hi,
    Is it possible to maintain multiple payment formats with in a single program.
    For example let us assume that we have created 2 payments formats as 'XX-PAY1' & 'XX-PAY2'.
    When i select the parameter as '1' then 'XX-PAY1' has to run else 'XX-PAY2'.
    if its possible could you please tel us where to define the parameters in Setups.
    Many thanks,
    Zaheer S

    nazzu wrote:
    Hi,
    Is it possible to maintain multiple payment formats with in a single program.
    For example let us assume that we have created 2 payments formats as 'XX-PAY1' & 'XX-PAY2'.
    When i select the parameter as '1' then 'XX-PAY1' has to run else 'XX-PAY2'.
    if its possible could you please tel us where to define the parameters in Setups.
    Many thanks,
    Zaheer SSounds like an Apps question. Start here: https://forums.oracle.com/forums/category.jspa?categoryID=3

  • Multiple Form Regions with a single Save button

    Hello,
    Is it possible to have multiple form regions on a single page, with a single Save button that commits changes in all form regions? If so, would the forms have to be manual forms?
    If that is not possible, or a bad way to go with APEX, what are my alternatives?
    I am trying to avoid the user having to click through many screens to input the data. Logically each section should be in a different table, but I would like to group some of the sections together to reduce the number of pages the users need to navigate to.
    Thanks in advance for your help,
    Johnnie
    Edited by: johnniebillings on Jun 1, 2009 9:33 PM

    Hi Johnnie,
    I assume that the tables are related somehow?
    If so, you can create a SQL View on the joined tables (making sure that you have a unique ID for each record in the view that can act as the Primary Key), base the form on that view and then use an INSTEAD OF trigger on the view to populate the individual tables.
    Andy

  • Replacing non-ASCII characters with HTML charcter references

    Hi All,
    In Oracle 10g or greater is there a built-in function that will convert a string with non-ASCII characters like this
    a b č 뮼
    into an ASCII string with HTML character references like this?
    a b & # x 0 1 0 D ; & # x B B B C ;
    (note I had to include spaces between each character in the sample code for message to prevent the forum software from converting my text)
    I tried using
    utl_i18n.escape_reference( val, 'us7ascii' )
    but for some reason it returns
    a b c & # x B B B C ;
    Note how it converted the Western European character "č" to its unaccented counterpart "c", not "& # x 0 1 0 D ;" (is this a bug?).
    I also tried a custom solution using regexp_replace and asciistr (which I can't include here because the forum software chokes on it) but it only returns the correct result for values <=4000 characters long. Unfortunately asciistr doesn't appear to accept CLOB values larger than 4000 characters. It returns an error message like
    (ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 30251, maximum: 4000) ).
    I'm looking for a solution that works on CLOB data of any size.
    Thanks in advance for any insight you can provide.
    Joe Fuda

    So with that (UTF8) in mind, let's take another look.....
    As shown below, I used a AL32UTF8 database.
    Note: I did not use a unicode capable tool for querying. So I set console mode code page to 1250 just to have č displayed properly (instead of posing as an è).
    Also, as a result of using windows-1250 for client character set, in the val column and in the second select's ncr column (iso8859-1), è (00e8) has been replaced with e through character set conversion going from server back to client.
    Running the same code on a database with a db character set such as we8mswin1252, that doesn't define the č (latin small c with caron) character, would yield results with a c in the ncr column.
    C:\>chcp 1250
    Aktuell teckentabell: 1250
    C:\>set nls_lang=.ee8mswin1250
    C:\>sqlplus test/test
    SQL*Plus: Release 11.1.0.6.0 - Production on Fri May 23 21:25:29 2008
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    With the OLAP option
    SQL> select * from nls_database_parameters where parameter like '%CHARACTERSET';
    PARAMETER              VALUE
    NLS_CHARACTERSET       AL32UTF8
    NLS_NCHAR_CHARACTERSET AL16UTF16
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'us7ascii') NCR from dual;
    VAL  NCR
    č e  c e
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'we8iso8859p1') NCR from dual;
    VAL  NCR
    č e  &# x10d; e     <- "è"
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'ee8iso8859p2') NCR from dual;
    VAL  NCR
    č e  č &# xe8;
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'cl8iso8859p5') NCR from dual;
    VAL  NCR
    č e  &# x10d; &# xe8;In the US7ASCII case, where it should be possible for all non-ascii characters to be escaped, it seems as if the actual escape step is skipped over.
    Hope this helps to understand whether utl_i8n is usable or not in your case.
    Message was edited by:
    orafad
    Fixed replaced character references :)

  • Comparison of multiple column values with a single column value

    I have two separate tables say Tab1 and Tab2
    I want to select some datas , which is common to both the tables.
    In tab1 , there is a column 'STATE' and it's value is 'A'
    In tab2, there are multiple columns for the state, say STATE_A,STATE_B, STATE_C ETC and a row is present with the following details
    STATE_A = 1, STATE_B =1 ,STATE_C =0,STATE_D=1
    I need to select STATE when STATE_A ='1',
    if my STATE='B', this STATE has to be selected since STATE_B =' 1', similraly
    if my STATE='D', this STATE has to be selected since STATE_D =' 1',
    If my STATE='C', STATE_C should not get selected since it's '0'.
    Is it possible to do this in a single SELECT statement, where I have some other checks also or else how can I achieve it?

    Maybe this will help
    Select * from STATE_MAS ;
    STATE
    A
    B
    D
    F
    H
    Select * from STATE_CHILD
      STATE_A   STATE_B   STATE_C   STATE_D   STATE_E   STATE_F   STATE_G   STATE_H   STATE_I   STATE_J
            1         0         0         1         1         0         0         0         0         0
    CREATE OR REPLACE FUNCTION GET_STATE (P_VAL VARCHAR) RETURN NUMBER IS
    V_SQL VARCHAR2(200);
    V_COL VARCHAR2(35);
    P_RETURN NUMBER ;
    BEGIN
    V_COL := 'STATE_'||P_VAL;
    V_SQL := 'SELECT 1 FROM STATE_CHILD WHERE '||V_COL||' = 1 ';
    EXECUTE IMMEDIATE  V_SQL INTO P_RETURN ;
    RETURN P_RETURN ;
    END;
    SELECT STATE FROM STATE_MAS
    WHERE GET_STATE(STATE) = 1 ;
    STATE
    A
    D

  • Replace Non-Numeric Characters with a Numeric Character in a String

    Hi Guys,
    I need to replace all the non-numeric characters (including embedded blanks & hyphen) in a string to a numeric character '1'.
    The trailing blanks should not be replaced.
    e.g. "P22233344455566" should be changed to "122233344455566"
    &    "49-1234567           " should be changed to "4911234567          "
    Please help.

    Use [replace|http://help.sap.com/abapdocu_70/en/ABAPREPLACE_IN_PATTERN.htm] with a regular expression to translate any non-numeric character (i.e. any character not between 0 and 9) to 1:
      REPLACE ALL OCCURENCES OF REGEX '[^0-9]' IN value WITH '1'.
    Cheers, harald
    p.s.: In older releases [translate|http://help.sap.com/abapdocu_70/en/ABAPTRANSLATE.htm] would also do the trick, but is more lengthy, because one would need to specify each individual character that should be replaced, e.g.:
      TRANSLATE value TO UPPER CASE.
      TRANSLATE value USING
          ' 1_1-1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1'.

  • SSM - Configure Multiple Webserver's with a Single Database Server

    Hi,
    I need to install SSM using the following system landscape: Distributed system using a single database server and two webserver's.
    The system is configured to use the Microsoft Network Load Balancing and that's the reason why exist two webserver's. When the user put the URL, the connection can be done to the webserver 1 or webserver 2 (the Microsoft Network Load Balancing will manage that).
    I was checking the install guide "NW CE 7_1 SP5 SQL Server Install Guide.pdf" but there is no reference to this system landscape. The only "similar" is for High Availability System using Microsoft Cluster Service (MSCS), but that's not what I need.
    I was planning to do a distributed installation and in the database server I will install:
    - the Database Instance of NetWeaver
    - the Database components of SSM (PAS)
    In the Webserver I will install:
    - the SCS Instance of NetWeaver
    - the Primary Application Instance of NetWeaver
    - the Web components of SSM (PIP, etc...)
    For a scenario of a single webserver and a single database server, this work just fine.
    My questions are:
    - how can I configure SSM to work in a scenario of two webserver's and a single database server?
    - Should I install the same components in both WebServer's?
    - Should I use the same instance number or a different one?
    - It is possible to have two netweaver instance sharing the same database?
    Thanks in advance for all the help
    Regards
    Pedro

    Hi Pedro,
    - how can I configure SSM to work in a scenario of two webserver's and a single database server?
    Yes see below. But also make sure SAP will support the configuration you're planning!
    - Should I install the same components in both WebServer's?
    yes.
    - Should I use the same instance number or a different one?
    The same makes configuration eaiser
    - It is possible to have two netweaver instance sharing the same database?
    Not for the SCS but yes for application server (your Java instances)
    The central services, SCS instance, are one per a SAP System. So you cannot install one on each Web Server and operate them simultaneously.
    Given your database is also a single point of failure then I would suggest you install the SCS with it on the database server.
    On each of the Web Servers install an application instance of SAP NW CE.
    Since the instance are on different servers they can share the same instance number.  It is not mandatory but it may make configuration easier. e.g. for the the webservice the port will not change.
    There can only be one Interactive Publisher (PIP) running so this may as well also go on your database server.
    The Pilot Application Server (PAS) there can be multiple of so install one on each Web Server.
    See section 5.2.3 of Server Installation Guide SAP Strategy Management Release 7.0 Support Package 2 and higher for configuring SAP NW CE to point to the one instance on Interactive publisher.
    See section 5.2.7 of Server Installation Guide SAP Strategy Management Release 7.0 Support Package 2 and higher for setting up the Web Service target in Interactive publisher this will need to use the virtual ip(or hostname) of your Network Load Balancer.
    Best of luck.
    Marcel.

  • How can I open multiple email messages with a single click?

    On the Mac mini I use at work, I can select several email messages at a time and open them all up by double-clicking the mouse pointer on any of the selected messages. My MacBook Pro at home seems to lack that functionality, even though both are running the same version of Yosemite. In order to open up multiple messages (each, in its own window) on my MacBook Pro, I need to double-click on each individual message, even though I have multiple messages selected on my MacBook Pro, using Yosemite's Mail app. I assume there is an optional setting that can enable multiple messages to be opened by double-clicking on a single selected message, but I have looked through the Mail app's preferences and I come up empty handed. Can someone please clue me in on how to get this functionality on my MacBook Pro?

    Hi,
    There is another similar icon named Bookmarks in the '''Customize''' window which provides the said functionality. You have to add that.

  • Blue Screen (STOP: 0x00000050) when using multiple Agilent34970A devices with a single GPIB

    Hi,
    I am using two test fixtures that contain two Agilent34970A Multimeters and two Sorensen Power Supplies (each test fixture is contaning one Multimeter and one Sorensen Power Supply) that are connected via GPIB cables to a single PCI-GPIB card. Below I have attached two VI's. GPIB_Communication_Experiment_1.vi (Test Fixture 1) and
    GPIB_Communication_Experiment_2.vi (Test Fixture 2) are used to run self test on the
    Agilent34970A multimeters. GPIB_Communication_Experiment_1.vi is talking to one of the Agilent Multimeters and one of the Sorensen Power Supplies (Address 9 for Agilent Multimeter and Address 2 for Sorensen Power Supply) whereas GPIB_Communication_Experiment_2.vi talks to the second Agilent Multimeter and its Sorensen Power Supply (Address 10 for the Multimeter and Address 3 for the Sorense Power Supply).
    The Problem occurs when I try to run these two VI's simultaneously where it generates a "blue screen of death" with a Technical Information : STOP: 0x00000050 (0xF8AC00440, 0x00000000, 0x8041889, 0x00000000).
    This Problem only occurs when trying to run the executables that were built from the attached VI's.
    I have tried to use VISA CLEAR within the while loop as you can see in the VI however it did not improve things.
    I have also uninstalled and re-installed the software for my PCI-GPIB card but that seemed not to work either.
    At this point I am confused.  If I try to run only one Test Fixture at a time I have no problem doing the Self Test on the Agilent Multimeter, yet every single time if I try to run the two test fixtures together I am  gettig the blue screen.
    Besides the two executable VI's I have also attached the regular VI's
    I would really appreciate your help, thanks in advance for your time.
    Attachments:
    GPIB_Communication_Experiment_1.vi ‏23 KB
    GPIB_Communication_Experiment_2.vi ‏23 KB

    Hello aps7828:
    If I read that correct, you only get the error when you run the executables and not the VIs. Can you take a look at your processor level while one .exe is running. I am wondering if that is the source of the problem.
    Regards,
    Roland A.
    Applications Engineer
    National Instruments
    Check out VI Roadshow

  • How to replace non-alphanumeric characters with " "  in a String?

    Hi,
    Anyone can help with this?
    I guess I should use the replaceAll-method??

    I need to keep characters that are generally ok to
    use in
    sentences, like ".", ",", "!", and "-" and alsoall
    digits and letters
    (numbers and alphabetic characters).Add those characters to the pattern in that case. Add
    them just before ]
    but placing the '-' char as the last in the list.

  • Using multiple XML Connectors with a single trigger

    I have an application, which I inherited, and it had used a
    HUGE XML file, and has not been performing properly. Mgmt accepts
    that the size of the XML is the problem and wants it split up, but
    have it still work as if it were a single file.
    The question posited to me was: Can I set up multiple XML
    connectors and have the correct one triggered after a selection is
    made from the Combo Box?
    I am only an intermediate user and am getting these things
    only because the other developer is retiring. Thank you for any
    ideas/assistance.

    Hello aps7828:
    If I read that correct, you only get the error when you run the executables and not the VIs. Can you take a look at your processor level while one .exe is running. I am wondering if that is the source of the problem.
    Regards,
    Roland A.
    Applications Engineer
    National Instruments
    Check out VI Roadshow

Maybe you are looking for

  • Need help setting up xrdp server on my Arch

    Hey, I want to set up an XRDP/VNC server on my personal computer which is running the latest Arch linux (X64). I wanted to use xrdp as I am going to connect to my computer from a windows based OS (work). I want to be able to do so using microsoft's R

  • How do I change date time stamp

    I've been trying to Adjust the date and time stamp on photos in iphoto and it keeps changing the date by subtracting days and minutes instead of simply changing the date and time to what I type in. What am I doing wrong?

  • 270 dollar zen extra broken after short warranty left high and

    My Zen Xtra is fi've months old I haven't dropped it and when I picked it up to use the other day it wouldn't work. It turns on and visually looks as though its playing a song but no sound comes out. The menu works until you try to do something that

  • PPP-assigned DNS Configuration

    I am using wvdial and it successfully connects to the Internet but then it gives this error: "Timeout waiting for the PPP-assigned DNS configuration."  I searched the web for this and found a Russian website and a Spanish website.  I can read neither

  • MacPro crashes all the time

    Hi My  MAC PRO   OSX 10.6.8 2 x 3 GHZ Dual Core Intel Xeon 7 GB 667 MHZ DDR2 FB-Dimm crashes all the timei checked the harddisc, repaired perission , zapped pram, disconnected devices. etc etc Screen goes suddenly grey/black ( like a wave from up to