How to replace multiple occurences of space in a string to a single space?

How to replace multiple occurences of space in a string to a single space?

Hi,
try this code.
data : string1(50) type c,
          flag(1) type c,
          dummy(50) type c,
          i type i,
          len type i.
string1 = 'HI  READ    THIS'.
len = strlen( string1 ).
do len times.
if string1+i(1) = ' '.
flag = 'X'.
else.
if flag = 'X'.
concatenate dummy string1+i(1) into dummy separated by space.
clear flag.
else.
concatenate dummy string1+i(1) into dummy.
endif.
endif.
i = i + 1.
enddo.
write : / string1.
write : / dummy.

Similar Messages

  • How to replace multiple files in same location Indesign CS6

    Hi everyone please help me with this challenge if you are avialable it will be greatly appreciated!
    Ok I have a spread of about 60 pages in indesign.  I created a template where I have differnt PDFs in each section.  I have 3 different PDFs per page totalling about 180 different PDF docs in my in design file.  Every week I have to go in to replace those PDFs with the new ones.  They have to be in the exact same place and sized the same way since they are setup to print on one of our printers.  In indeesign CS3 I would just do Command D and then I would select all 180 PDF documents.  It would import all of them and I would just click on each area of the PDF holding down "Option" and it would automatically size the PDF to fit in the same way the previous PDF was.  Basically just replacing it.  I did this for all 180 relatively simple.  Now that feature is gone!  I can't for hte life of me figure out how to do this.  I've tried everything and it's not working.
    Can any one help me?

    Make Object style to your frames and setting the Frame Fitting Options>Fitting
    Also try: tomaxxiPlace2 script, i test it with indesign cs6 and it work fine.
    http://indisnip.wordpress.com/2011/01/13/script-tomaxxiplace2/#more-960

  • How to find multiple occurences in Hashtable

    I have a hashtable in which elements are stored with their values. Elements (keys) are labelled as
    Dept_1_2
    Dept_1_3
    Dept_2_3
    etc
    Now if I want to access all occurrences that start with letters Dept, how can I do that?? Should I use some kind of Regular Expression for pattern matching or is there other way?
    Thanks in advance

    Hashtable doesn't provide any method to do this. You will have to write a function that looks through the keys (hashtable.keys()) and perform the check (key.startsWith("Dept")) for each key.

  • Parse for multiple occurences of something in query string used

    HI
    A varchar is passed as an input to a stored proc. This could have zero, one or more occurances of a word (e.g. from_no). This will be in form of a name value pair and could occur multiple times. Exampe
    query_string = ' abc=123 and from_no > 1 and from_no < 10 and def = 1'
    Now I need to parse this string to get the operator and values for the 2 occurences of from_no. How can I do that? How can I go about writing a smple func or sp to parse and return both from_no's?

    Perhaps this sample code can help:
    with yourtable as
    (select ' abc=123 and from_no > 1 and from_no < 10 and def = 1' query_string from dual union all
    select ' abc=123 and from_no = 2 and from_no != 30 and def = 1 and from_no=40' query_string from dual)
    select  query_string,
            x.n no,
            regexp_substr(query_string,'from_no *[<>!=]* *[0-9]*',1,x.n) exp,       
            regexp_replace(regexp_substr(query_string,'from_no *[<!>=]* *[0-9]*',1,x.n),'.*from_no *([<!>=]*) *([0-9]*).*','\1') op,
            regexp_replace(regexp_substr(query_string,'from_no *[<!>=]* *[0-9]*',1,x.n),'.*from_no *([<!>=]*) *([0-9]*).*','\2') val
    from yourtable,
         (select rownum n from dual connect by rownum<=100) x
    where regexp_instr(query_string,'from_no',1,x.n)>0   --  end searching in query string when there are no more expressions
    order by query_string, x.nI added one more example.
    It works with your example, but you will have to adapt the code for your real environment.
    This code supports only the operators: =, !=, <, >
    This code supports only numeric values without decimal-point.
    Edited by: hm on 19.10.2010 22:46

  • How to convert tabs between the words in a String to a single space in java

    I have a string with more number of tabs in between them, the thing I need to do is that I need to convert all those tabs into a single space.
    I used replaceAll(“/t”,” “); but the problem is that it was converting the tabs into spaces but if we have a 3 tabs in between 2 words then this 3 tabs are converting into 3 spaces but I need to have only one space.

    user548049,
    How is your question related to the topic of this forum: Oracle Database-embedded JVM?
    Anyway, you need to use the greedy qualifier: +, like so:
    replaceAll("\\t+"," ")Good Luck,
    Avi.

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

  • How to download multiple ALV Container data on a screen to a single Excel?

    Hi,
    I have an output screen wherein there is plain text and 3 ALV list containers with different types of data and I need to provide a functionality to the user to be able to download all this data on the output screen to a single excel sheet.Is there some standard function module or any specific way of achieving this? Please help with this.
    Regards,
    Aditi

    Hi,
    create a pushbutton  on the toolbar,
    whenever user clicks the pushbutton,
    call the fm gui_download for three times
    for the first time,
    append = ' ',
    and for second time and third time.
    append = 'X'.
    Regards.

  • 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

  • How to replace the root tag in ABAP Mapping

    how to replace the root tag with the certain string in ABAP Mapping
    just like
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
         <name>Lawrence</name>
    </root>
    into
    <?xml version="1.0" encoding="UTF-8"?>
    <myRootElement>
         <name>Lawrence</name>
    </myRootElement>
    i don't want to implement it in message mapping
    please give me the sample code
    thanks in advance

    Use below code
    odocument = ixmlfactory->create_document( ).
    msgtype = odocument->create_simple_element(
    name = 'myRootElement'
    parent = odocument ).
    Thanks
    Praveen

  • Replace all occurrences of ENTER in a string

    Hi,
    I have a string which contains line breaks:
    '<HTML><HEAD>
    </HEAD>
    <BODY>'
    and it is shown to me in the debugger as:
    '<HTML><HEAD>#</HEAD>#<BODY>'
    Now I want to replace all line breaks in the string,
    but
    replace all occurrences of `#` in text with ' '.
    doesn't work.
    So if you have an idea how to replace the # symbol for Enter in a string please tell me ;).
    regards,
    Stefan

    Hi,
    Pls use
    replace all occurences of '#' in text with cl_abap_char_utilities=>newline.
    Eddy

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

  • 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

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

  • How to find and replace multiple cells at a time

    I am doing repetitive work re find text in numbers but then replace following cells with text. How can I find and replace multiple cells at a time?
    i.e. doing my own budget spreadsheet and coding all transactions with description and code

    Did you try the "Find/Replace" dialog box?:
    Then click the "Replace All" button in the bottom left.

Maybe you are looking for