You may match the end of line that has no character immediately to the right:
$(?![\w\W])
Here, $
matches an end of line position and (?![\w\W])
is a negative lookahead that fails the match if any char appears immediately to the right of that location.
See the regex demo where m
flag is enabled and makes $
match end of line positions, as in Visual Studio Code, and due to (?![\w\W])
it only matches at the very end of the text.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.