Reputation: 10531
String:
abc|c|xyz
Pattern:
|[^|]*
I hope this will only match '|xyz', but it matches '|c|xzy'. Why is it that? My pattern means that "start with '|' and any following character can't be '|'". Right?
Upvotes: 0
Views: 263
Reputation: 3366
Vim isn't matching "|c|xzy" There are two separate matches, "|c" and "|xyz". You can verify this by pressing n to jump between them.
It seems you only want the last match. You can add "$" to ensure your pattern only matches the end of a line:
|[^|]*$
Upvotes: 2