samedi 25 avril 2015

Why the * regular expression indicates what can or cannot be it's previous character


Take this for an example which I found in some blog, "How about searching for apple word which was spelled wrong in a given file where apple is misspelled as ale, aple, appple, apppple, apppppple etc. To find all patterns

grep 'ap*le' filename

Readers should observe that the above pattern will match even ale word as * indicates 0 or more of previous character occurrence."

Now it's saying that "ale" will be accept when we are having ap*le , isn't the "ap" and "le" fixed?

Thanks in Advance.


Aucun commentaire:

Enregistrer un commentaire