How to find the index of a praticular word in the whole sentence
i want 开发者_运维问答to find a text named "footer= XXX" in a text document and replace the XXX with my own value. The problem here is that this footer value repeats in lot of areas in the document with different values assigned to it. Any idea of how to do it?
str.replace(/footer=(.*?)\s/g, 'footer=whatever');
See it on jsFiddle.
You didn't mention what the end delimiter is, so I used white space. You may want to use a word boundary (\b
).
精彩评论