Spaces in string

Dear Gurus,
I have a string .
'My name is Roshan Lilaram Wadhwani'
I need to find the number of spaces used in this string.
Rather i need to segregate the string in two parts after a particular number of spaces.
Regards,
Roshan Lilaram.

TRY THIS
DATA : TEXT(50)  VALUE 'My name is Roshan Lilaram Wadhwani',
       LEN TYPE I,
       POS TYPE I,
       COUNTER TYPE I,
       V_CH,
       V_SPACE VALUE ' ',
       V_TXT(30),
       V_TXT2(20).
COMPUTE LEN = STRLEN( TEXT ).
DO LEN TIMES.
V_CH = TEXT+POS(1).
IF V_CH EQ SPACE.
  COUNTER = COUNTER + 1.
ENDIF.
IF COUNTER LT 3.
  CONCATENATE V_TXT V_CH INTO V_TXT.
ELSE.
  CONCATENATE V_TXT2 V_CH INTO V_TXT2.
ENDIF.
POS = POS + 1.
ENDDO.
WRITE : / V_TXT.
WRITE : / V_TXT2.
REGARDS
SHIBA DUTTA

Similar Messages

  • Adding white spaces between strings during concatenation in JSTL

    Please provide a way to add white space between strings during concatenation in JSTL.
    I tried the following.
    eg:
    <c:set var="even_odd" value="odd">
    <c:out value="first ${even_odd}"/>
    I want the output string as "first odd ".
    Moreover i am using the above value for generating the class attribute of a row of a table like
    <tr class=<c:out value="first ${even_odd}"/>>
    while printing the value of <c:out value="first ${even_odd}"/> in the page,i am getting correctly as i needed as "first odd".
    But while taking the code of the page while rendering by the browser, it is showing like
    <tr class="first" odd="">
    I think the white space is the problem.
    Please provide any solution or hint.

    <tr class=<c:out value="first ${even_odd}"/>><tr class="first ${even_odd}">

  • NULL option of column command - ignore word after space in string

    Hi,
    I'm quit new to Oracle and SQL world.
    building simple SQL/Plus report through SQL Developer enviroment:
    I'm trying to use NULL option of COLUMN comand to output a meaningful string instead null.
    But, any word after space in string.
    Followings are what I wrote on worksheet and excute 'Run Script'.
    COLUMN firedate NULL 'active';
    COLUMN mentorid NULL 'no mentor';
    select lastname, firstname, mentorid, firedate from members;
    refer to line (COLUMN mentorid NULL 'no mentor';) the out put for the MentorId, display word no and ignore any word after space which is here word mentor.
    My environment:
    SqL Developer ver. 3.1.07.
    Oracle database 10g Express edition (10.2.0.1.0)
    windows XP
    Much appreciated.

    SQL Developer is still not 100% SQL Plus compatible. It may be that this isn't implemented properly yet.
    Does it work in SQL Plus?

  • How to delete Spaces in String

    Can somebody help to modify my source, cos i want to delete certain space. Thanks
    private static String printStar(int SpaceForStar){
        String sDelOneSpace =" ", sAddOneSpace=" ", star ="*", sTtlSpace ="";
        for(int i=0; i<numSpace; i++){
          sTtlSpace += sAddOneSpace;    
        for(int i =0; i<8; i++){
          sTtlSpace = sTtlSpace - sDelOneSpace;   // seem that not working.. can somebody help Thanks
        return sTtlSpace+star;
      }Thanks in advance
    jas

    What you are trying to do will not work - subtraction of Strings does not make any sense.
    To remove spaces, I suggest you use a StringTokenizer with space as dividing token. Lop trough the tokens and add them to a new String, like this:
        public static void main (String[] args) throws Exception {
            String withSpace = "aaa sss bbb";
            System.out.println(removeSpaces(withSpace));
        static String removeSpaces(String withSpaces) {
            java.util.StringTokenizer t = new java.util.StringTokenizer(withSpaces, " ");
            StringBuffer result = new StringBuffer("");
            while (t.hasMoreTokens()) {
                result.append(t.nextToken());
            return result.toString();
        }This will remove all spaces, and print "aaasssbbb". If you only want to remove the first or the last space, you can use indexOf() or lastIndexOff to find the space, and then substring to pick the text before and after that space and concatenate those two strings to a new string without the space:
        static String removeFirstSpace(String withSpaces) {
            int spaceIndex = withSpaces.indexOf(' '); //use lastIndexOf to remove last space
            if (spaceIndex < 0) { //no spaces!
                return withSpaces;
            return withSpaces.substring(0, spaceIndex)
                + withSpaces.substring(spaceIndex+1, withSpaces.length());
        }

  • Help :how to remove spaces in string

    could any body please help me in removing spaces from string suppose i have written vivek chhabra and i want to remove spaces in this string and want a string vivekchhabra then how this could be done
    anybody help me please
    vivek

    String string = "Hello - This is a test!";
    String result = string.replaceAll(" ", "");
    System.out.println(result);This code results the following output:
    Hello-Thisisatest!

  • How to handle spaces in string?

    Hi,
    I am trying to filter out servers and certain OS from my powershell line below but I am getting an error. I think it is because of the Mac OS X line with spaces?:
    The string is missing the terminator: '
    $AllADClientObjects=@(Get-ADComputer -Filter "operatingSystem -notlike '*server*'" -and "operatingSystem -notlike '*"'Mac OS X'*'" -ErrorAction SilentlyContinue)

    Try this:
    $AllADClientObjects = @(Get-ADComputer -Filter "operatingSystem -notlike '*server*' -and operatingSystem -notlike '*Mac OS X*'")
    You shouldn't need the -ErrorAction SilentlyContinue when using filter because if it doesn't find anything, it will not throw an error like if you used -Identity.
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Search for White space within strings

    create table emp_dtl
    (empname varchar2(23));
    Insert into emp_dtl values ('WAYNE');
    Insert into emp_dtl values ('JOSEPH KRUPP');     --------- has white space
    Insert into emp_dtl values ('YING ZONG LEE');    --------- has white space
    Insert into emp_dtl values ('COHEN');
    Insert into emp_dtl values ('MARIE');How can i search for empnames which has White space in it? From other OTN threads, I gathered that this has something to do with
    chr(32)But i don't know how to put this in LIKE operator.

    Hi,
    SELECT  *
    FROM    emp_dtl
    WHERE   REGEXP_LIKE (empname, '\s')
    ;will look for any kind of whitespace (including spaces, which are CHR (32)).
    It may be more efficient to specifically list all the different whitespace characters, and see if the string changes when you remove all of them:
    SELECT     *
    FROM     emp_dtl
    WHERE     empname != TRANSLATE ( empname
                           , 'x ' || CHR (9)     -- CHR (9)  = <tab>
                                          || CHR (10)     -- CHR (10) = <newline>
                                 || CHR (13)     -- CHR (13) = <return>
                           , 'x'
    ;Edited by: Frank Kulash on Jul 12, 2010 8:47 AM

  • Making space for string (character) in Java

    A permutation is a function. In this particulate exercise, the function is certain space separation of an adjacent letter. Here is an example for the space is 2: After the first letter A, skip 2 spaces and arrive at D, skip another 2 space to arrive at G, so original ABC maps to adg.
    ABCDEFGHIJKLMNOPQRSTUVWXYZ
    maps to (with skip of 2 space):
    adgjmpsvybehknqtwzcfilorux
    You need to have a user input for the skip space, similar to the lab 1. Warning: Because there are 26 characters in the English alphabetic, if user enters an even number, you need to consider add one every time it passes the Z letter. Please help me to solve this problem.

    Try using this code segment:
    String abcString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    StringBuffer tempBuffer = new StringBuffer();
    StringBuffer outBuffer = new StringBuffer();
    tempBuffer.append(abcString);
    i = 0;
    while(i < abcString.length())
    outBuffer.append(tempBuffer.charAt(i));
    i+=2;
    tempBuffer.setLength(0);
    All you really need to do is change what you're adding to I every time you go through the loop, make it user input. This is simply an example of how to do it.
    -Jason Thomas.

  • How to trim spaces from string in BMM layer?

    Hi friends,
    I need to trim spaces from the string. can you please give me syntax with example.
    Thanks

    Hi
    I have tried the below option , but it did not work . PS_D_PERSON
    PERSON_ID is char type in the data base oracle , and it is defined as varchar on the physical layer .
    So the table is loaded with space , i am not able to remove the space using trim both
    Thanks
    Sridhar.N

  • Remote white space from string

    Hi I need a method which will remove the spaces in a string eg "Hello World" -> "HelloWorld"
    I have the code below but it dosnt work for the obvious reason charAt() returns a char and im comparing to a string.
    Can anyone offer any help? Thanks
              public void removeSpace(String s)
              {     int rs = s.length();
                   String cat;
                   for (int i=0;i<rs;i++) {
                        cat = s.charAt(i).toString();
                        if (cat==" ") {
                             s.replace(""," ");
              }

    Hi I need a method which will remove the spaces in a
    string eg "Hello World" -> "HelloWorld"
    I have the code below but it dosnt work for the
    obvious reason charAt() returns a char and im
    comparing to a string.
    Can anyone offer any help? Thanks
              public void removeSpace(String s)
              {     int rs = s.length();
                   String cat;
                   for (int i=0;i<rs;i++) {
                        cat = s.charAt(i).toString();
                        if (cat==" ") {
                             s.replace(""," ");
    Hi,
    You can't modify the contents of a String, you must create a new String, and use that one. Your code should be:
    public String removeSpace(String s) {
        return s.replaceAll(" ", "");
    }The returned string is the string without spaces.
    /Kaj

  • Using Bash/Applescript to get rid of spaces in string

    Hi Community,
    Is there a way through Bash (or if not, through applescript) to delete the spaces in a string? ie. turn the string "hi my name is batman" to "himynameisbatman". Thanks.

    As you can see, there really are a rediculous number of ways to accomplish this task! Here are a couple more AppleScript examples...
    --DO SHELL SCRIPT EXAMPLE
    set theString to "hi my name is batman"
    do shell script "echo " & quoted form of theString & " | tr -d ' '"
    --PURE APPLESCRIPT EXAMPLE
    set theString to "hi my name is batman"
    (words of theString) as string

  • Removing \n and leading spaces with String.replaceAll()

    I am trying to format a large XML string that contains carriage returns and lines with leading spaces. Something like this (pseudo example)...
    s: "<a>
    ��<b>some text</b>
    ��<c>
    ����<d>more text</d>
    ��</c>
    </a>"When i am done, i want it to look like this...
    s: "<a><b>some text</b><c><d>more text</d></c></a>"I have tried using replaceAll() in this way....
      s = s.replaceAll("^\\s+","");// to remove leading spaces
      s = s.replaceAll("\\n","");// to remove carriage returnsHowever, I am not getting the results I expect. In fact, the entire string seems to simply turn into all whitespace....
    s: "                                           "My question is: Is there an easier way? (or at least a way that works?)

    try this:
    public String transformXML(String s) {
        s = s.replace("^\\s+", "");
        s = s.replace("\\s+$", "");
        s = s.replace("\\s+", " ");
        s = s.replace("\\s*<\\s*([^<>]*?)\\s*>\\s*", "<$1>");
        return s;
    }which would transform your example expression from:
    <a>
    <b>some text</b>
    <c>
    <d>more text</d>
    </c>
    </a>
    to probably what you want:
    <a><b>some text</b><c><d>more text</d></c></a>
    Hope this helps~
    Alex Lam S.L.

  • Remove spaces in String

    Lets say I have a String like this " 323232323 3434324". How do I remove the spaces in the beginning so I get the following result "323232323 3434324" ?
    It's not a fixed number of spaces in the beginning. It could also be e.g " 323232323 3434324"

    I think this should work:
    String otherString;
    String yourString = "    12345";
    for( int i = 0; i < yourString.length(); i++ ){
       if ( yourString.charAt(i) != ' ' ){
          otherString = yourString.subString( i );
          break;
    }

  • Spaces in string updated to database..stored in database as  

    hello! i m facing a wierd problem here. i hope someone can help me as soon as possible..
    the string that i want to insert into the database has spaces..for example "Harley Davidson Shirt". And when this string is added into the database..the record is stored as ====> Harley Davidson Shirt
    i am not sure why the spaces are translated into  . as a result of this..wen i retrieve back the values that i inserted n display it..it still displays as ====> Harley Davidson Shirt <== wid all the   in between
    just in case..this is my servlet code..the servlet that adds the string into the database. the string i am trying to add in this OrdersTemp table in the database is actually retrieved from another table called PetProduct in the same database.
    ==============================================================
    * Created on 2/11/2004
    package servlets;
    import java.io.IOException;
    import javax.servlet.http.*;
    import javax.servlet.*;
    import beans.database.*;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2004</p>
    * <p>Company: </p>
    * @author Administrator
    * @version
    public class AddToCartServlet1 extends HttpServlet {     
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              processRequest(request, response);     
    private void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
    String driverName = this.getServletContext().getInitParameter("Access Driver");
    String connectionStr = this.getServletContext().getInitParameter("Access Connection String");
    String mySqlJndiName = this.getServletContext().getInitParameter("MySql JNDI");
    String database = request.getParameter("database");
    DataRetriever db;
    db = new DataRetriever();
    if ( !db.connect(driverName, connectionStr, "admin", "pets") ){                                           
    request.getRequestDispatcher("/WEB-INF/pages/DatabaseError.jsp").forward(request, response);
    String name = null;
    String petProductId[] = request.getParameterValues("add");
    for (int ctr = 0; ctr < petProductId.length; ctr ++) {
         DataRow mama = db.execSelectQuery("Select PetProductID, ProductName From PetProduct where PetProductID = " + petProductId[ctr] + "");
         List list = new ArrayList();
         while ((list = (List)mama.nextRecord()) != null) {
              for (Iterator it = list.iterator(); it.hasNext();) {
                   String id = it.next().toString();
                   name = it.next().toString();
         String sql = "Insert into OrdersTemp(PetProductId, ProductName) VALUES ('" + petProductId[ctr] + "', '" + name + "')";
         db.execUpdateQuery(sql);
    DataRow data = db.execSelectQuery("Select PetProductId, ProductName from OrdersTemp");
    request.getSession().setAttribute("data", data);
    request.getRequestDispatcher("/WEB-INF/pages/PetProductPurchaseConfirmation.jsp").forward(request, response);
    }

    You probably need to change the database encoding. Just a guess since your code doesn't reveal the problem area!!!!!!!!

  • Preserve spaces between strings...

    Hi everyone,
    I an trying to extract some data to a flat file in a format that each column has start and end positions.
    I am trying to pad some "spaces" after each column to get my requirement.My code is not preserving the
    spaces between each string.
    This is what i have..
    But the strange thing i found is..i ran the following code
    declare
    final_str varchar2(100);
    begin
    final_str := rpad('12',4)||rpad('12',4);
    insert into test(col1) values (final_str);
    end;and it is preserving the spaces .
    Is there anything wrong with my code.I need to preserve the spaces after each string.
    Please help me to solve this issue..
    Thanks

    Hi Phani,
    If you use chars instead of varchar2's you keep fixed lengths.
    F.i.:
    SQL> declare
      2    a varchar2(50);
      3    b char(50);
      4  begin
      5 
      6    for rec in ( select level*100 l from dual connect by level <= 5)
      7    loop
      8      a:=rec.l;
      9      b:=rec.l;
    10      dbms_output.put_line('>'||a ||'< (lenghth a = '||length(a)||')');
    11      dbms_output.put_line('>'||b ||'< (lenghth b = '||length(b)||')');
    12    end loop;
    13  end;
    14  /
    100< (lenghth a = 3)
    100 < (lenghth b = 50)
    200< (lenghth a = 3)
    200 < (lenghth b = 50)
    300< (lenghth a = 3)
    300 < (lenghth b = 50)
    400< (lenghth a = 3)
    400 < (lenghth b = 50)
    500< (lenghth a = 3)
    500 < (lenghth b = 50)
    PL/SQL procedure successfully completed.

Maybe you are looking for

  • Private key file from acs 3.3

    Hi All ,            I have my SSL server certficate on my old acs 3.3.along with private key file , How i can export this private file with .pem extension from windows 2000 server , This private key file is not identified under certficate mmc console

  • ORA-14189: this physical attribute may not be specified for an index subpar

    Hi, I have many partition table and their subpartition and also I create index partition ans index subpartition. I moved partition table another new tablespace and then when I rebuild partition indexes I am getting below error. ORA-14189: this physic

  • Network users no being able to open/see iCloud documents

    I have a local network. All the network users are working without any glitch. They are able to use mail/contacts/etc from iCloud. iWork is able to open/see only local/network files but iCloud ones. Is anyone having the same problem?

  • Regarding Partner Type LI (Vendor) configuration

    Hi All, My scenario is File > XI> IDOC (INVOIC02 Idoc) Partner Type LI I had configured WE20 in receiving System for Partner Type LI and given the Process code details. Now in XI what are the steps that i need to configure( For Partner Type LI Vendor

  • Raw wont open for canon 5d

    ive tried everything and it still wont work...