Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Been Zaidi

Greenhorn
+ Follow
since Mar 21, 2012
Been likes ...
IntelliJ IDE Tomcat Server Chrome
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Been Zaidi

Norbert Muench wrote:

Been Zaidi wrote:From the console here is the input given


In my opinion, the instruction is asking to find one or zero match of aa. But here is the output generated


No, the ? only binds to the second a, so the pattern that regex is looking for is one 'a' followed by zero or one 'a'
To look for one or zero matches of aa, the regex would be "(aa)?".

Been Zaidi wrote:Another additional thing, inside the book it is written that the engine backtracks as well. Why is that so?


Imagine you have the regex ".*c" and are looking for a match in "abc". Since the * is greedy, the initial match for the beginning of the regex (".*") would be as long as possible, therefore matching the whole string. But then the end of the regex wouldn't fit anymore, so the pattern matching has to backtrack, making .* only match ab instead of abc.



Dear Nobert,

I am able to understand the first part of your explanation. It was very helpful. Thanks a lot.

The quoted part, i am a little confused. Can you elaborate it a little simply. Looking forward to hear.

Thanks,
Hi,
I was reading greedy quantifier in K&B. I came across zero-length match which are pretty tricky. Here is a slight modification
to the exam and that's the input given from the console



From the console here is the input given


In my opinion, the instruction is asking to find one or zero match of aa. But here is the output generated



Can someone explain this behavior. Another additional thing, inside the book it is written that the engine backtracks as well. Why is that so?

Thanks,
Thanks piyush.

I will look into it.

Thanks,
Been
Hi,

I finished the section for greedy quantifiers and regular expressions from K&B. Can someone point me towards some
practice references for Regex and greedy quantifers with respect to the exam?

Thanks,
Ben
Dear Henry,

Thanks for clarification. It helped me clarify my concept.

Thanks,
Been
Dear Philip,

Thanks. I have yet another last confusion. When we say it with (), it stores the matching value. Can you elaborate over this a little.
With use of parenthesis and without use of it.

Thanks a ton,
Been
Dear Philip,

Your post was very helpful. So basically the key is this expression. Please correct me if i am wrong. When we write



It basically means that it can be anything except a comma. It can be a digit, character or anything but it shouldn't be a
comma. Plus * means zero or more ocurances. Please correct me if i am wrong.

Thanks,
Been
Hi.
I am reading Chapter-6 from Kathy and Bert Book. I am on the topic of quantifiers. Here is an example from K&B to use
a regular expression to find all file names starting with proj1. Here is the example


"proj3.txt,proj1sched.pdf,proj1,proj2,proj1.java"



Regular expression give to find such a combination is



It states that the key part to the expression is to use zero or more findings of characters that is not a ,.
It doesn't give any character regex like \w then how come we can state find zero or more occurance of characters that is not a ,.
Can someone elaborate please?

Best Regards,