Reputation: 2970
So i am cleaning up a .txt in Notepad++ getting rid of some crap data by using the Find and Replace. here is an example of what i have
3
http://i2.ytimg.com/vi/Wkan7AqnIpQ/hqdefault.jpg
https://www.gravatar.com/avatar/903847782a309d54b4cc065a5db01674?s=128&d=identicon&r=PG
3
https://i.sstatic.net/qKWlS.jpg?s=128&g=1
https://www.gravatar.com/avatar/69e84fb0e0943636b7de859b6db5eaf4?s=128&d=identicon&r=PG
6
NOTE: underneath 6 is an empty line
What i want to do is find all the lines which only have a single character in them since they wont be valid urls. my own research lead me to this question which is where i started using this
\w{1,}
however this was getting me every group of numbers and letters (each group separated by symbols). so i thought to add \r\n
since the lines i want removed would always contain the newline characters. it limited the results but it was getting me the end of every line which at text.
i also tried [0-9]{1,}\r\n
because at this time i am only expecting numbers on single lines and this reduces the results more but the .imgur link is bring picked up as well because of the 1 at the end.
So what else can i do so i can get rid the lines which only have 1 character in them?
Upvotes: 1
Views: 1514
Reputation: 240878
You can use anchors, (^
start), ($
end) in order to determine if there is only a single character on that line (example):
^\w$
You may also need the m
multi-line flag in order to match the start/end of each line rather than the start/end of the entire string.
Upvotes: 3