G
gregpinero
I'm trying to write a little script that will have a list of word pairs
which will loop through that list and replace all instances of each
word with the other word.
I'm very new to javascript so I'm not quite sure where to get started.
Here is my python "prototype" in case you want a better idea of what
I'm trying to do:
<code>
corpus="""
We always love war. Run away all of you he ordered.
""" #Just some random text I made up. This would be the html in the
javascript version
findreplacepairs=[
("war","peace"),
("run","walk"),
("order","request")
]
for item in findreplacepairs:
\t corpus.replace(item[0],item[1]) #replaces all instances
</code>
Thanks,
Greg
which will loop through that list and replace all instances of each
word with the other word.
I'm very new to javascript so I'm not quite sure where to get started.
Here is my python "prototype" in case you want a better idea of what
I'm trying to do:
<code>
corpus="""
We always love war. Run away all of you he ordered.
""" #Just some random text I made up. This would be the html in the
javascript version
findreplacepairs=[
("war","peace"),
("run","walk"),
("order","request")
]
for item in findreplacepairs:
\t corpus.replace(item[0],item[1]) #replaces all instances
</code>
Thanks,
Greg