3. In slide 22, the regexp given will not match any of the example lines shown, but [Bb]ush( +[^ ]+){1,5} debate will. (The difference is that the repeated pattern in this one does not end with " +".)
There are several significant errors in this lecture. 1. In slide 13, the explanation given for why the regular expression matches the last line is incorrect. The "." matches exactly one character. It will never match an empty string. In the case of the last line in that slide, the regular expression matches the substring "9911" of the line, and therefore, the "." is matching the second 9 of this substring.
4. The parenthesized subexpressions (of the given example lines) matched by the regular expressions given in slides 26 and 27 will be identical (contrary to what Prof. Peng implies). This is because the regular expression in slide 27, namely, ^s(.*?)s$ has an end-of-line anchor ($) at the end, and all the example lines happen to end with the character "s". Therefore, as far as these examples is concerned, the "?" modifier (which is the subject of slide 27) will actually have no effect.
2. Slide 20 is misleading because it suggests that the given regular expression will match only lines that contain a "(" followed by a ")" (with 0 or more arbitrary characters in-between). The fact is that that regular expression will match *any* line whatsoever, whether it includes parentheses or not. The regular expression that represents your examples would be \(.*\) or, better yet, \([^)]*\)
Great walkthrough - I've been forcing my way through this subject for awhile, but I'm glad I finally took the time to properly walk through slowly with good explanations. As usual, your presentations are always gentle to absorb and not overwhelming! Thanks for the link to this in your rPub book 'R Programming for Data Science' which is equally well done.
Why, between slides 20 and 21, does the (.*) suddenly NOT refer to open or closed parentheses? I.e. the thing being searched for (with anything or nothing in the middle). There are no parentheses in slide 21 but it only means anything between a numeric.
@gb590212h 10 years ago 2. Slide 20 is misleading because it suggests that the given regular expression will match only lines that contain a "(" followed by a ")" (with 0 or more arbitrary characters in-between). The fact is that that regular expression will match *any* line whatsoever, whether it includes parentheses or not. The regular expression that represents your examples would be \(.*\) or, better yet, \([^)]*\)
3. In slide 22, the regexp given will not match any of the example lines shown, but
[Bb]ush( +[^ ]+){1,5} debate
will. (The difference is that the repeated pattern in this one does not end with " +".)
thanks - answered my question
Thank you, I literally was working on this issue for several hours thinking I was doing something wrong...apparently I was not...
There are several significant errors in this lecture.
1. In slide 13, the explanation given for why the regular expression matches the last line is incorrect. The "." matches exactly one character. It will never match an empty string. In the case of the last line in that slide, the regular expression matches the substring "9911" of the line, and therefore, the "." is matching the second 9 of this substring.
He definitely teaches this better than Jeff Leek (professor in the same dept), in my humble opinion.
4. The parenthesized subexpressions (of the given example lines) matched by the regular expressions given in slides 26 and 27 will be identical (contrary to what Prof. Peng implies). This is because the regular expression in slide 27, namely,
^s(.*?)s$
has an end-of-line anchor ($) at the end, and all the example lines happen to end with the character "s". Therefore, as far as these examples is concerned, the "?" modifier (which is the subject of slide 27) will actually have no effect.
just write it as
^s(.*?)s
right?
2. Slide 20 is misleading because it suggests that the given regular expression will match only lines that contain a "(" followed by a ")" (with 0 or more arbitrary characters in-between). The fact is that that regular expression will match *any* line whatsoever, whether it includes parentheses or not. The regular expression that represents your examples would be
\(.*\)
or, better yet,
\([^)]*\)
Great walkthrough - I've been forcing my way through this subject for awhile, but I'm glad I finally took the time to properly walk through slowly with good explanations. As usual, your presentations are always gentle to absorb and not overwhelming! Thanks for the link to this in your rPub book 'R Programming for Data Science' which is equally well done.
Why, between slides 20 and 21, does the (.*) suddenly NOT refer to open or closed parentheses? I.e. the thing being searched for (with anything or nothing in the middle).
There are no parentheses in slide 21 but it only means anything between a numeric.
@gb590212h
10 years ago
2. Slide 20 is misleading because it suggests that the given regular expression will match only lines that contain a "(" followed by a ")" (with 0 or more arbitrary characters in-between). The fact is that that regular expression will match *any* line whatsoever, whether it includes parentheses or not. The regular expression that represents your examples would be
\(.*\)
or, better yet,
\([^)]*\)
really clear to understand thanks
Thank you very much for this!
lwwetuo
Thanks
Thank you.
GOD bless you.
can i get sample code