![]() Last thing that I've found is that if I add -P to interpret the pattern as a Perl-compatible regular expression, it doesn't seem to keep the -w description that says that the substring "must be either at the end of the line or followed by a non-word constituent character", since it matches n1= even though it's followed by the character 1, which is a word constituent character ( "letters, digits, and the underscore"). If I add n= to different places in the line (without a following word character after the equal sign), it will match those as well, but again it will ignore n3=3. ![]() The goal of the question is to understand how grep works. So for instance, if the string is n1=1 n2= n3=3 n4= n5, the expected result should be: n1Ĭlarification: I know that the goal can be achieved by grep -ow -e 'n' -e "n=*", but that's beside the point. A substring that begin with n followed by any number of = characters and ends with a non-word character.n preceded and followed by a non-word character.What am I missing here? Is there any explanation for this behavior, or is it some sort of bug in grep? Or if I tell it to match only n2 or n3, again it matches the first one, and ignores n3. I would expect that it would match n1, n2 and n3, but it matches only the first one. I'm trying to understand why grep -w (version 3.1 of the GNU implementation) matches only the first occurrence of a certain pattern in a line.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |