/    Sign up×
Community /Pin to ProfileBookmark

Replace various strings in Dreamweaver doc

Folks –

In Dreamweaver I have a Command that searches through the page and replaces all foreign letters with their proper code [for example, a ‘u’ with umlauts becomes ü]:

function canAcceptCommand(){return true;}
function convertForeignText() {
var theDOM = dw.getDocumentDOM();
var theDocEl = theDOM.documentElement;
var theWholeDoc = theDocEl.outerHTML;
theDocEl.outerHTML = escapeExtended(theWholeDoc);
window.close();
}
function escapeExtended(s){
return s.replace(/([x80-uffff])/g, function (a, b) {
var c = b.charCodeAt();
return “&#” +c+”;”
});
}

What I’d like to have is another Dreamweaver command that will do the same, except it will replace all instances of a string with another string, so for example all strings equal to “Hello world” would be replaced with “Hello world”, and all “Good Night” would be replaced by “good night”, etc etc

Presumably it will need an array which can contain all of the strings to look for and all of their replacements, but beyond that I don’t know what to do! Anyone got a bit of javascript to do this?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @jonnyi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...