Results 1 to 7 of 7
Thread: "\\s" delimiter
- 01-20-2012, 02:16 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 11
- Rep Power
- 0
- 01-20-2012, 02:26 AM #2
Re: "\\s" delimiter
Please show the method and class that you are using that String in.
- 01-20-2012, 02:35 AM #3
Member
- Join Date
- Dec 2011
- Posts
- 11
- Rep Power
- 0
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]);
- 01-20-2012, 02:43 AM #4
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: \\
- 01-20-2012, 03:17 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: "\\s" delimiter
Read the following. You can find the answer there.
Regexp Tutorial - Character Classes or Character Sets
- 01-20-2012, 03:27 AM #6
Member
- Join Date
- Dec 2011
- Posts
- 11
- Rep Power
- 0
- 01-20-2012, 03:32 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: "\\s" delimiter
You are welcome.
Before use the regex you can use the validation tools/environments like Regular Expression Library.
Similar Threads
-
Got struck with this :- " Exception in thread "main" java.lang.NullPointerException"
By Vermont in forum New To JavaReplies: 5Last Post: 12-21-2011, 06:44 PM -
connection = DriverManager.getConnection(DATABASE_URL,'"+userid +"','"+password+"');
By renu in forum New To JavaReplies: 3Last Post: 10-12-2010, 04:21 PM -
How to change my form design from "metal" to "nimbus" in Netbeans 6.7.1?
By mlibot in forum New To JavaReplies: 1Last Post: 01-21-2010, 09:20 AM -
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")
By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 06:56 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks