Related Examples
  1. String Array to Collection Example
  2. String Array Content Example
  3. String Declare Example
  4. String Array to ArrayList Example
  5. String Array Example
  6. Java String valueOf Example
  7. Java String trim Example
  8. Java String toUpperCase Example
  9. Java String toString Example
  10. Java String toLowerCase Example
  11. Java String toCharArray Example
  12. Java String substring Example
  13. Java String indexOf Example
  14. Java String startsWith Example
  15. Java String hashCode Example
  16. Java String matches Example
  17. Java String length Example
  18. Java String lastIndexOf Example
  19. Java String isEmpty Example
  20. Java String equalsIgnoreCase Example
  21. Java String equals Example
  22. Java String endsWith Example
  23. Java String copyValueOf Example
  24. Java String contentEquals Example
  25. Java String contains Example
  26. Java String concat Example
  27. Java String compareToIgnoreCase example
  28. Java String compareTo example
  29. Java String codePointCount Example
  30. Java String codePointBefore Example
  31. Java String codePointAt Example
  32. Java String charAt Example
  33. Java String valueOf(Object obj) Example
  34. Java String valueOf(long l) Example
  35. Java String valueOf(int i) Example
  36. Java String valueOf(float f) Example
  37. Java String valueOf(double d) Example
  38. Java String valueOf(char[] data, int offset, int count) Example
  39. Java String valueOf(char[] data)Example
  40. Java String valueOf(char c) Example
  41. Java String valueOf(boolean b)Example
  42. Java String trim Example
  43. Java String toUpperCase(Locale locale)Example
  44. Java String toUpperCase Example
  45. Java String toString Example
  46. Java String toLowerCase(Locale locale) Example
  47. Java String toLowerCase Example
  48. Java String toCharArray Example
  49. Java String substring(int beginIndex, int endIndex)Example
  50. Java String substring(int beginIndex)Example
  51. Java String subSequence(int beginIndex,int endIndex)Example
  52. Java String startsWith(String prefix,int toffset) Example
  53. Java String startsWith(String prefix)Example
  54. Java String split(String regex) Example
  55. Java String split(String regex)Example
  56. Java String replaceFirst Example
  57. Java replaceall CharAt Example
  58. Java String replace(char oldChar) Example
  59. Java String regionMatches(int toffset)Example
  60. Java String regionMatches(boolean ignoreCase)Example
  61. Java String matches Example
  62. Java String length Example
  63. Java String lastIndexOf(String str,int fromIndex)Example
  64. Java String lastIndexOf(String str)Example
  65. Java String lastIndexOf(int ch, int fromIndex) Example
  66. Java String lastIndexOf Example
  67. Java String isEmpty Example
  68. Java String intern Example
  69. Java String indexOf(String str,int fromIndex)Example
  70. Java String indexOf(String str) Example
  71. Java String indexOf(int ch, int fromIndex) Example
  72. Java String indexOf(int ch)Example
  73. Java String hashCode Example
  74. Java String getChars(int srcBegin) Example
  75. Java String getBytes(Charset charset) Example
  76. Java String getBytes Example
  77. Java String format(String format)Example
  78. Java String format(Locale l) Example
  79. Java String equalsIgnoreCase Example
  80. Java String equals Example
  81. Java String endsWith Example
  82. Java String copyValueOfchar[] Example
  83. Java String copyValueOf Example
  84. Java String contentEquals Example
  85. Java String contains Example
  86. Java String concat Example
  87. Java String compareToIgnoreCase Example
  88. Java String compareTo Example
  89. Java String codePointBefore Example
  90. Java String CodePointAt Example
  91. Java String CharAt Example
  92. Java String codePointAt Example
  93. Java String Class

View All Examples
 

Java String split(String regex) Example

String class split(String regex) method example


String class split(String regex) method example. This example shows you how to use split(String regex) method.This method Splits this string around matches of the given regular expression.
Syntax:-split(String regex, int limit)

Here is the code:-
/* 
 * @(#) Splitstring1.java
 *Program Shows a class Splitting string around matches of the given regular expression.
 * @Version  01-May-2008
 * @author   Rose India Team
 */
 
import java.util.regex.Pattern;
class Splitstring1 
{
private static String REGEX = "=";
private static String INPUT = "Welcome=to=Rose=India=.net";
public static void main(String[] argv) {
/*A compiled representation of a regular expression.
  regular expression, specified as a string, must first be compiled into an instance of this class.*/
Pattern p = Pattern.compile(REGEX);
// editing your input file, regex.txt 
String[] items = p.split(INPUT,3);
for (int i = 0; i < items.length; i++) {
System.out.println(items[i]);
}
}
}

null

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US