Using the star sign in grep
By : Ahmad Dallah
Date : March 29 2020, 07:55 AM
wish of those help The asterisk is just a repetition operator, but you need to tell it what you repeat. /*abc*/ matches a string containing ab and zero or more c's (because the second * is on the c; the first is meaningless because there's nothing for it to repeat). If you want to match anything, you need to say .* -- the dot means any character ( within certain guidelines). If you want to just match abc, you could just say grep 'abc' myFile. For your more complex match, you need to use .* -- grep 'abc.*def' myFile will match a string that contains abc followed by def with something optionally in between. Update based on a comment:
|
GREP - Regex +(plus) vs. *(star) performance
By : Buso
Date : March 29 2020, 07:55 AM
|
grep: When should the kleene star(*) match itself?
By : Bill Batey
Date : March 29 2020, 07:55 AM
this one helps. * on its own is an invalid regular expression since there is no previous item to repeat. Your implementation of grep, in this case, interprets it as a literal *. \* is a valid regular expression which matches a *. Your implementation's interpretation of the invalid regular expression * and the valid regular expression \* just happen to be the same. If you really want to see the difference between * and \*, you should try it on a valid regular expression by adding an item before it. For example, a literal a: code :
grep 'a*'
grep 'a\*'
|
Using grep to search a string with a star(*)
By : shugenghuang
Date : March 29 2020, 07:55 AM
this will help grep interprets its pattern as a regular expression, so * means repetition of the previous character (or subexpression). Use grep -F to get rid of this behavior.
|
grep/egrep the star operator not matching all occurrences
By : Cleon And
Date : March 29 2020, 07:55 AM
seems to work fine Let's take the string AaAa. I want to match the as: , Let's start with this: code :
$ echo AaAa | grep -o 'a*'
$
2.5.3
=====
Fix the combinations:
* -i -o
* --colour -i
* -o -b
* -o and zero-width matches
Go through the bug list im my mailbox and fix fixable.
Fix bugs reported with 2.5.2.
$ echo AaAa | grep -o 'a*'
a
a
$
|