How do I search for pattern that is not at the beginning of a line?Ex:Name1 Name2 Name3 Name4 Name5 Name6Something like:/[^^]Name.Obviously the second ^ symbol does not mean beginning of line inside []. Is there any symbol that means not at the beginning of line?
How to search for a pattern that starts at newline in ex/vi
regular expression;original vi
In original vi, and in tools with POSIX BRE or ERE, there's no way to look for strings not at the beginning of the line. However, in all of these, you can use regex groups to match any character before your actual target pattern, and then keep it unchanged in the replacement.In general, when you want to insert something between two strings, you use groups, like so:s/\(pattern1\)\(pattern2\)/\1 foo \2/Correspondingly, to match something not at the beginning of the line, it will be the second pattern, and a . will be the first. And for patterns not at the end of the line, it will be the first, and a . the second: