Search pattern examples
"0:4.10.5-5.el7"
"0:0.7.7-13.20120626.ov7"
"6:4.14.8-6.po7_3"
- How to search and print all occurrences like above patterns where the first number can be any number ranging from 0-9 separated by ":" trailing with any number or alphabet ranging from a-z separated by . or. in vi editor ?
I could search the occurrences of all the patterns starting with any number [0-9] separated by ":" using
:%s/[0-9]\+\:
- how to remove all the occurrences till end of line of each occurrence
```
. And add what you want the result to be./\d:[0-9a-z\.]\+
if you want to match your examples you'll need to add_-
to[0-9a-z\.]
. 2) Your second question is not clear: do you want to remove everything after the:
in this case you can use:%s/\d\+:\zs[0-9a-z\.]\+//
. If you want to remove all the lines matching the previous pattern you can use a global command like:g/\d\+:[0-9a-z-\.]\+/d
. Maybe try to clarify your question so that we can answer it precisely.