I would recommend to use the new git filter-repo, which replaces  BFG and git filter-branch.
Note: if you get the following error message when running the above-mentioned commands:
Error: need a version of `git` whose `diff-tree` command has the `--combined-all-paths` option`
it means you have to update git.
First: do that one copy of your local repo (a new clone)
See "Content base filtering":
At the end, you can (if you are the only one working on that repository) do a git push --force
If you want to modify file contents, you can do so based on a list of expressions in a file, one per line.
For example, with a file named expressions.txt containing:
p455w0rd
foo==>bar
glob:*666*==>
regex:\bdriver\b==>pilot
literal:MM/DD/YYYY==>YYYY-MM-DD
regex:([0-9]{2})/([0-9]{2})/([0-9]{4})==>\3-\1-\2
then running
git filter-repo --replace-text expressions.txt
# on Windows
git-filter-repo --replace-text expressions.txt
  ^^^
will go through and replace:
- p455w0rdwith- ***REMOVED***,
- foowith- bar,
- any line containing 666with a blank line,
- the word driverwithpilot(but not if it has letters before or after; e.g. drivers will be unmodified),
- the exact text MM/DD/YYYYwithYYYY-MM-DDand
- date strings of the form MM/DD/YYYYwith ones of the formYYYY-MM-DD.
gaborous adds in the comments:
On Windows, git-filter-repo works as a separate Python module (that you can install as such using pip install), so you need to add a dash in the above command for it to work on Windows:
git-filter-repo --replace-text expressions.txt