Hello Friend. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
Hello Satish. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
can we use multiple matcher objects in one class? I tried to do so, i had no compile time errors but i'm geting the "java.lang.IllegalStateException".. The code is below: import java.util.regex.*; public class CharClass { public static void main(String[] args) { Pattern p = Pattern.compile("[^abc]"); Matcher m = p.matcher("adbcalsdics"); while (m.find()) { System.out.println(m.start() + " " + m.group()); } Pattern p1 = Pattern.compile("[123]"); Matcher m1 = p1.matcher("12343fery65e@(%^G"); while (m1.find()) { System.out.println("Secong matcher object" + m.start()); } } } output: 1 d 5 l 6 s 7 d 8 i 10 s Exception in thread "main" java.lang.IllegalStateException: No match available at java.util.regex.Matcher.start(Unknown Source) at gameOn.CharClass.main(CharClass.java:16)
if(m.find()== true){ while (m.find()) { System.out.println(m.start()+"----"+m.group()); //System.out.println("yes"); } } else{ System.out.println("Not Matching"); } This will execute your desired output but It is not needed
Thanks a lot Durga sir..................🙏🙏🙏🙏🙏🙏
Who teaches java like a God?
One straight answer-Durga sir🎉
Hello Friend.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
Sir your teaching is exceptional thank you
Hello Satish.
Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos.
You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link:
goo.gl/kqvaf2
Please upload remaining web services tutorials.thanks a lot,Sir for uploading tutorials,Superrrbbb, awesome ,very nice and very clear explanation.
can we use multiple matcher objects in one class? I tried to do so, i had no compile time errors but i'm geting the "java.lang.IllegalStateException".. The code is below:
import java.util.regex.*;
public class CharClass {
public static void main(String[] args) {
Pattern p = Pattern.compile("[^abc]");
Matcher m = p.matcher("adbcalsdics");
while (m.find()) {
System.out.println(m.start() + " " + m.group());
}
Pattern p1 = Pattern.compile("[123]");
Matcher m1 = p1.matcher("12343fery65e@(%^G");
while (m1.find()) {
System.out.println("Secong matcher object" + m.start());
}
}
}
output:
1 d
5 l
6 s
7 d
8 i
10 s
Exception in thread "main" java.lang.IllegalStateException: No match available
at java.util.regex.Matcher.start(Unknown Source)
at gameOn.CharClass.main(CharClass.java:16)
You are getting start index on matcher(m) not on m1
System.out.println("Secong matcher object" + m.start());
I know it's a very late reply ;)
@@UdayKumar-df9so yes u r right change that m object
I have a doubt when while condition goes false then too how it executes further? ?
+Megha Sahu the while lop will execute as long as the condition stays true,,if the condition is found to be false the loop does'nt execute at all.
if(m.find()== true){
while (m.find())
{
System.out.println(m.start()+"----"+m.group());
//System.out.println("yes");
}
}
else{
System.out.println("Not Matching");
}
This will execute your desired output but It is not needed