Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. String s1="Java is oop probgramming, R1|R2|R4|R5|R";
  2. String s2="R";
  3. String s3="R2";
  4. String s4="R5";
  5.  
  6. System.out.println(s3.matches(s1.substring(Options1.indexOf(","), s1.indexOf("|"))));
  7. System.out.println(s2.matches(s1.substring(Options1.indexOf(","), s1.indexOf("|"))));
  8.  
  9. String s1="Java is oop programming, R1|R2|R4|R5|R";
  10. String s2="R";
  11. String s3="R2";
  12. String s4="R5";
  13. String[] validTargets = new String[]{s2,s3,s4};
  14.  
  15. String alternatives = s1.split(",")[1].trim();
  16. for(String s: alternatives.split("|")){
  17. for(String t: validTargets){
  18. if(s.matches(t)) { //you can also use equals() here..
  19. System.out.println("they are matched!");
  20. }
  21. }
  22. }
  23.  
  24. s1.contains(s2);
  25. s1.contains(s3);
  26.  
  27. System.out.println(s1.matches("(?i).*"+s2+"*"));
  28. System.out.println(s1.matches("(?i).*"+s3+"*"));
  29. System.out.println(s1.matches("(?i).*"+s4+"*"));
  30.  
  31. s1 = s1.substring(s1.indexOf(","));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement