I have what most of you will probably consider a trivially easy problem to solve.
I have a list which is formatted like so;
?d?d?d?d?l?d?d?d
?d?d?d?d?l?d?d?l
?d?d?d?d?l?d?d?u
?d?d?d?d?l?d?l?d
?d?d?d?d?l?d?l?l
There are many tens of thousands of lines like this. I would like a regular expression that will select all of the lines that contain more than 5 occurrences of the letter d
so they can be removed from the list.
Despite searching extensively, I have not found a solution that works. I've found many ways of searching for occurrences of characters etc. on this and other forums (including spaces and special characters), and have been able to successfully conduct the search on other lists of words but I think the presence of all those question marks screws it up... I can't say for sure though.
I apologise in advance if I somehow missed a post which explains this perfectly, but I have made an effort to find a solution on my own and have just become exasperated with it.
Many thanks in advance for any help provided!
Use Find and Replace and replace lines matching the following with nothing:
^.*(d.*){6}.*\r\n
Explanation:
^
- start at beginning of a line.*
- skip 0 or more uninteresting characters but not past end of line(d.*)
- find d followed by any uninteresting characters but not past end of line{6}
- repeat the last group exactly six times (so 6 (d followed by anything)) (use {6,}
for 6 or more).*
- match any remaining characters up to end of line\r\n
- match end of line sequence (as pointed out by @toto, better as \R
)See https://regex101.com/r/UaYAz4/1
Update based on comments:
^[^d\r\n]*(d[^d\r\n]*){6,}.*\R