Here is the scenario. I have a file named "censoredwords.txt", where there is one word or phrase per line, which might contain punctuation (such as an apostrophe or exclamation point). I have a second file name "replacewords.txt" where there is one word or phrase per line, which is used to replace the "censored word" on that same line number from the "censoredwords.txt" file.
Then I have a source file. The source file is a text file that needs a script to search for each line item contained in the "censoredwords.txt" file, and replace all such occurrences from the corresponding line number in the "replacewords.txt" file.
Here is the catch, it should only apply changes to lines where there is an "=" character, and only change what is to the right of the first "=" character it finds, but all occurrences of each word to the right of that character should be changed.
I'm afraid my mind is mud this week. I'm averaging less than 3 hours sleep per night taking care of my teething baby. Anyone that can provide a script that can do this, I would be very grateful.
Sample files?
censoredwords.txt
- Code: Select all
gorgon
wraith
tarantula
replacewords.txt
- Code: Select all
monster
ghost
spider
source file
- Code: Select all
$txt['monster'] = 'The gorgon ate the statue.';
$txt['ghost'] = 'The wraith passed through the wall to attack the gorgon with a gorgon eating tarantula.';
$txt['spider'] = 'The tarantula laid an egg containing tarantula larvae inside the gorgon, which ate the gorgon from the inside out. This made the ghost happy.';


