Regex to display the initial letters of the sentences replacing the remaining letters with asterisks or dots
- Ctrl+H
- Find what:
(?<![^a-z])(?<!^)[a-z]
- Replace with:
.
- UNCHECK Match case
- CHECK Wrap around
- CHECK Regular expression
- Replace all
Explanation:
(?<![^a-z]) # negative lookbehind, make sure we haven't a non-letter before
(?<!^) # negative lookbehind, make sure we aren't at the beginning of line
[a-z] # a letter
Screenshot (before):
Screenshot (after):
You just need a regular expression to identify the characters that you want to convert. That is simple, either of the following will work: \B\S
, or \B\w
.
Now you need a tool to convert all matched characters to a .
I don't use notepad++, so I can't speak to how you would to it there. But this is simple using my JREPL.BAT regular expression find/replace command line utility.
Let's assume you want to do the conversion to the file "file.txt":
jrepl "\B\S" "." /f file.txt /o -
or
jrepl "\B\w" "." /f file.txt /o -
If you put the command within a batch script, then you need to use call jrepl
because JREPL is itself a batch script. Without CALL you will not return back to your script.
You can also transform piped text. Here is a simple example:
C:\test>echo hello world|jrepl "\B\S" "."
h.... w....
Powershell Version Based on @dbenham RegEx
(Get-Content "Filepath") -replace '\B\w','.' | Set-Content "Filepath"