We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Strings
- Java String Tokens
- Discussions
Java String Tokens
Java String Tokens
Sort by
recency
|
1790 Discussions
|
Please Login in order to post a comment
String [] tokens = s.trim().split("[^A-Za-z]+"); int n = tokens.length; System.out.println(n); for(String token: tokens){ System.out.println(token); }
Who is using s.split(...) and failing tests 3,6,7,10, change it to s.trim().split(...) and it will pass! You are welcome!
Issue encountered on some test case Tried inputing test using test cases and have expected output
}
This is a classic string manipulation and tokenization challenge, often seen in programming exercises like those on HackerRank. New Play Exchange Login
import java.io.; import java.util.; import java.util.regex.*; public class Solution {
}