Replacing multiple spaces with another character

i need to replace multiple spaces with another char in a string
my code is
Dim text as String="a bit much             a little much" Dim arr As String() = text.Split({" "c}, StringSplitOptions.RemoveEmptyEntries)Dim newtext As String = String.Join(" ", arr)            MsgBox(newtext)           
 it returns to "a bit much  a little much "
But i want to replace only long spaces with "="  as  "a bit much =a little much"
How can i do that?

This version uses two spaces to split the string and then trims any additional single spaces. It returns "a bit much = a little much".
Dim text As String = "a bit much a little much "
Dim parts() As String = text.Split({" "}, StringSplitOptions.RemoveEmptyEntries)
Dim newText As String
If parts.Length = 2 Then
newText = parts(0).Trim & " = " & parts(1).Trim
End If

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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

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

  • HELP : Replacing Space with any character !

    Hi !
    How do I replace any spaces in a strings passed from a FORM INPUT, with a different character.
    I tried doing this
    String s= request.getParameters("info");
    s.replace(' ','_');
    But it keep giving me error.
    it there any simpler way of doign this?
    Thank you
    K

    Hi !
    I am new to JSP,
    It keep giving a null pointer exception when i use it with JSP
    So i did this it work fine on the try section
    and once it is in the catch section it keeps giving me Nullpointer exceptions again.
    IS there any other way replacing the space with a "-" or anything..?
    Thanks for your help.
    here is the code
    String r_space ="";
    try {
         r_space=value.replace(' ','+');
         out.println("r_space : try " r_space "<br>");
    catch(NullPointerException e) {
    System.out.println("Recaught: " + e );
    r_space=value.replace(' ','+');
    out.println("r_space : cathc" r_space "<br>");

  • Replacement Path Variable with Another Variable

    Hi,
    I am currently trying to create a report that would need me to have the same values for different characteristics (e.g. clearing date, posting date, net due date). I have seen that there is a way in the replacement path variable that would replace its value with another variable that is ready for input. I also looked into SAP help but I can't seem to figure out on how to do it specifically. Does anyone know a step-by-step process on how to do this? How does this work?
    Thank you in advance!

    take an e.g.
    u have characteristic say ch1
    u want to restrict it with replacement path variable
    first of all create a variable var1
    click what it is based upon for e.g. 0calday, 0material etc.
    make it user entry variable
    select single or multiple entry
    make it mandatory
    save it and hit okey
    click on ch1
    right click and say restrict
    in new window create a new variable
    give its name and technical name
    processing path is replacement path
    go to next tab of replacement path
    select several ooptions
    replace variable with another variable
    select a variable called var1
    change the offset length and offset start with different parameters.
    hit okey
    this way u have restricted ch1 with replacement path variable var1
    now when u run report u have to enter value of var1
    which will then further feeded to ch1
    this way u can create replacement path variables at lots of instances and then u can always feed the value from var1 at different time
    make sure as this ur requirement is date
    try to use 0calday as reference infoobject all the times....

  • How to replace one variable with another in large number of queries

    Hello guys!
    I have this situation: our company needs to use one variable instead of another for certain amount of queries.
    Is there some way to automatically replace one variable with another for a certain characteristic in big number of queries ( like 150 - 200 ) ? Doing this manually would take lots of time)
    Apreciate your help!

    you could try (at your own risk) the following:
    1. search the technical id (ELTUID) of your variable in table RSZELTDIR
    2. see where this variable is used in table RSZELTXREF (by filling RSZELTDIR-ELTUIID in RSZELTXREF-TELTUID)
    3. add similar entries for your new variable
    4. delete the entries for the old variable (they're part of the key, so you can't simply "change" them)

  • How do I share multiple contacts with another iPhone?

    How do I share multiple contacts with another iPhone? Thanks in advance.

    What do you mean share? 
    It is not possible to send contacts from one iPhone to another without installing an app that would support this.  Bump is one such app.
    There is no functionality in iOS to do this.  iCloud can share contacts across multiple iDevices, but it would be ALL contacts, just just a few.

  • Since i got the new Iphone 4s it constantly drops calls. Apple have replaced the phone with another new iphone 4s but i am still having the same problem. I have checked with vodapohe that there is no issue from there end, given a new sim, still drops out

    Since i got the new Iphone 4s it constantly drops calls. Apple have replaced the phone with another new iphone 4s but i am still having the same problem. I have checked with vodapohe that there is no issue from there end, given a new sim, still drops out

    Have a look at this it might help
    http://support.apple.com/kb/TS4148

  • How to replace a movieclip with another movieclip

    How to replace a movieclip with another movieclip
    Hi,
    I am having a swf called tchild.swf... in this i got a
    movclip 'child1'. i am loading this tchild.swf into another swf
    tparent.swf within 'mcloader' movie clip.. i got another movclip
    called 'picture1'
    i am loading tchild.swf into mcloader movclip.. and i want to
    load 'child1' moviclip into picture1..
    how to replace a picture1 movieclip with child1 mc..
    PS: i dont want to load picture1 from library.. its on the
    stage.

    AWT or Swing?

  • Replace multiple spaces

    Hi dear experts,
    I need a function/procedure that replaces multiple spaces by one space.
    (This is because of an Application Express representation of strings in a report).
    (I have to replace ' ' by '_' in this post just because of the same phenomenon).
    Strings like "This___is_an_________example"
    should become " This_is_an__example".
    I need something like:
    create or replace function remove_multispaces(text_in in varchar2) return varchar2 is
    begin
    while instr(text_in,'__') >0 /* two blanks */
    loop
    execute immediate replace (text_in,'__','_'); /*replace 2 blanks by 1 */
    end loop;
    return (text_in);
    end remove_multispaces;
    But this is definitely not working.
    Thank you for your help,
    Hergen.

    SQL> ed
    Wrote file afiedt.buf
    1 create or replace function replace_multispaces(in_str varchar2) return varchar2 is
    2 out_str varchar2(100):=in_str;
    3 begin
    4 while(instr(out_str,'__')>0) loop
    5 out_str:=replace(out_str,'__','_');
    6 end loop;
    7 return(out_str);
    8 exception
    9 when others then
    10 dbms_output.put_line(sqlerrm);
    11* end;
    SQL> /
    Function created.
    SQL> select replace_multispaces('This___is_an_________example') from dual
    2 ;
    REPLACE_MULTISPACES('THIS___IS_AN_________EXAMPLE')
    This_is_an_example
    SQL>

  • Powershell (Replacing White Spaces with a comma)

    The object property values output tends to be tabular with varying white spaces between each column. I’m looking for a script that will allow me to:
    Output the object property values to a file
    Remove all white spaces encountered (regardless of the number of spaces)
    Replace the spaces with one (1) comma
    Replace isn’t the answer unless I literally define each instance of spaces and I can’t find any discernable documentation on using Regex…
    -- formattting the output doesn't help either...
    Any guidance / help would be appreciated
    Roderick

    Let's say I ran the PowerShell command below:
    Get-ClusterResource  -Cluster ClusterName | Where-Object {$_.Name -like "SQL Server (*"}
    The output would be something along lines of what you see below.
    I typically output the result set to a csv file, strip the header, replace the spaces with a single comma, and bulk import the data into a SQL Server table for reporting.
    Basically, I'd like a "dynamic way" (not replace with the literal space count between double quotes) of getting rid of the spaces between the columns and replace the spaces with a single comma.
    Name                                        State          
    Group             ResourceType                            
    SQL Server (SRV101O)            Online           SRV101o            SQL Server                              
    SQL Server (SRV301O)            Online           SRV301o            SQL Server                              
    SQL Server (SRV201O)            Online           SRV201o            SQL Server                              
    SQL Server (REMSRV101O)      Offline           REMSRV101o     SQL Server                              
    SQL Server (REMSRV301O)      Offline           REMSRV301o     SQL Server                              
    SQL Server (REMSRV201O)      Offline           REMSRV201o     SQL Server                              
    SQL Server (REMSRV401O)      Offline           REMSRV401O     SQL Server                              
    SQL Server (REMSRV501O)      Offline           REMSRV501O     SQL Server                              
    SQL Server (SRV401O)             Online          SRV401O            SQL Server                              
    SQL Server (SRV501O)             Online          SRV501O            SQL Server                              

  • Qosmio X500-10W - Can I replace the HDD with another one?

    Hello
    I have a Qosmio X500-10W with two HDD Toshiba MK5055GSX 500GB 5400RPM 8MB ??SATA II but is one of hs so I wonder if I can be replaced by a more powerful style HDD 750GB 7200tr / min 16MB Toshiba course?
    merci

    Hey,
    Your question is a little bit hard to understand but I think you want to replace the HDD with another (faster) model, right?
    Well, thats no problem. HDDs with 7200rpm will work, they are a little bit louder but they are faster so if you need more performance no problem.
    Also 750GB or more is no problem because SATA interface is not capacity limited. Theoretically 1TB or more should also work.
    Anyway, you can buy the 750GB you mentioned it will work. :)

  • Replace a string with another string in a file

    I have to replace a string with another string. Say for example in a html file it got a line like,
    <a href="##"></a>
    now i want to replace this ## with the full derived path like
    "c;\\sample folder\\sample subfolder\\samplefile.html"
    can someone help me to do this?
    pls tell me from the file opening till closing the file.

    I have to replace a string with another string. Say
    for example in a html file it got a line like,
    <a href="##"></a>
    now i want to replace this ## with the full derived
    path like
    "c;\\sample folder\\samplesubfolder\\samplefile.html"
    can someone help me to do this?
    pls tell me from the file opening till closing the
    file.
    public class Buckel {
      final static String CONST = "c:\\sample folder\\samplesubfolder\\samplefile.html";
      public Buckel() {
      public static void main ( String[] argv )  throws Exception {
        int    idx = 0;
        String in  = "<a href=\"##\"></a>",   // We'll imagine this just gets here somehow. If it's on the i/p file then take the '\' out B4 and aft the '##'.
               out = "";
        idx = in.indexOf( "##" );
        if ( idx > 0 ) {
          out = in.substring( 0, idx ) + CONST + in.substring( idx+=2, in.length() );
        System.out.println( out );
    }

  • 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

  • How to replace blank spaces with zero's in the report

    hai sdn guys,
                         we have a requirement where we cannot have any blank fields in the report and i need to replace the blanks with a zero. What is the best way to do it.

    Hi Sunitha,
    It is not proper that you are posting the same question multiple times:
    Re: report o/p should not have blank spaces in - in case of no value
    should get 0's in place of blank value in  the output of the report
    That too inspite of my requesting you not to do so.
    I am not sure if you have ever gone through the Rules Of Engagement which are prominently posted in each forum, but I think it is SDN courtesy to provide proper feedback when posting a question and assign points as deemed fit. This helps (and motivates) everyone to work on your problem and try to give you a solution. I hope you will be more careful in the future. Thanks!

Maybe you are looking for

  • Help Finding an Audio Interface

    So I'm looking for a device that can take an output from my mac pro (through either usb or maybe optical) and can send it to my two KRK Rokit 5's and my KRK Sub through XLR. Also it needs to have a 1/4" jack to plug my KRK KNS 8400's into. Can someon

  • How to create Settlement Rule

    Hello Experts, I need to create settlement rule for work order. Got one FM K_ORDER_SRULE_ADD but don't know how to use it. Is this FM correct one to create settlement rule? Can anyone please send sample code for FM? Thanks in Advance, Ripal.

  • Is it possible to load and read from an Oracle global temp table?

    Is there a way to call an Oracle database package to pre-load global temp tables in BIP? I am an Oracle Reports user but a newbie to BIP. In Oracle Reports, I use the before-reports trigger to execute a database package that will populate a temp tabl

  • New house need phone line

    i have just moved into a house and there is a bt box but when i plug a phone in there is nothing. the previous owners had virgin tv but stipulated that a bt phone line was connected to the house.  I ideally would like to get phone and broadband from

  • Trying to re-install Adobe CS4

    Trying to reinstall Adobe CS4 Design Premium, but it keeps hanging at "preparing to install". The disk is in good shape and everything. P.S. My operating system is Windows 7.