Results 1 to 7 of 7

Thread: "\\s" delimiter

  1. #1
    cris9288 is offline Member
    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0

    Default "\\s" delimiter

    When tokenizing a string, what does the "\\s" delimiter refer to? Thank you.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: "\\s" delimiter

    Please show the method and class that you are using that String in.

  3. #3
    cris9288 is offline Member
    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0

    Default Re: "\\s" delimiter

    Actually I was just reading an example. This is the bit of code I was looking at:


    Java Code:
    String[] result = "this is a test".split("\\s");
         for (int x=0; x<result.length; x++)
             System.out.println(result[x]);

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: "\\s" delimiter

    That String must be a regular expression. You need to find the doc for how to write regular expressions.

    The \ is a regular expression control character and also a java compiler escape character. To pass a single \ to the regexp you need to escape it for the java compiler: \\

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  6. #6
    cris9288 is offline Member
    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0

    Default Re: "\\s" delimiter

    Quote Originally Posted by Eranga View Post
    Read the following. You can find the answer there.

    Regexp Tutorial - Character Classes or Character Sets
    great! thank you!

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Replies: 5
    Last Post: 12-21-2011, 06:44 PM
  2. Replies: 3
    Last Post: 10-12-2010, 04:21 PM
  3. Replies: 1
    Last Post: 01-21-2010, 09:20 AM
  4. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •