Skip to content

Instantly share code, notes, and snippets.

@devlifeX
Created June 5, 2017 22:22
Show Gist options
  • Save devlifeX/a6c8ebc94dd5b2171c499c3c6432370c to your computer and use it in GitHub Desktop.
Save devlifeX/a6c8ebc94dd5b2171c499c3c6432370c to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/gezadal
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
const string = `idfir st_nÄmelÄst_~!@#$%^&*()_+=-\`<>?/.,{}[]:"|;'\"nÄmeemÄilg enderip_Äd dress idfir st_nÄmelÄst_ nÄmeemÄilg enderip_Äd dress
idfir st_nÄmelÄst_ nÄmeemÄilg enderip_Äd dress
1CedS inkinscsinki ns0@php.ne tMÄle226.2 34.216.15
`;
const replacerMethod2 = (content, replacChar) => {
let newContent = content;
const specialChar =
['~', '!', '@', '#', '$', '%', '^', '&',
'*', '(', ')', '_', '+', '=', '-', '`',
'<', '>', '?', '/', '.', ',', '{', '}',
'[', ']', ':', '\"', '|', ';', '\'', '\\', '\/'];
newContent = newContent.replace(new RegExp(specialChar.join('|\\'), 'g'), '');
newContent = newContent.replace(
new RegExp(Object.keys(replacChar).join('|\\'), 'g'), match => (
replacChar[match]
));
return newContent;
};
const indexAction = () => {
const replacChar = {
Ä: 'a',
Ü: 'u',
Ö: 'o',
' ': '-'
};
return replacerMethod2(string, replacChar);
};
console.log(indexAction());
</script>
<script id="jsbin-source-javascript" type="text/javascript">const string = `idfir st_nÄmelÄst_~!@#$%^&*()_+=-\`<>?/.,{}[]:"|;'\"nÄmeemÄilg enderip_Äd dress idfir st_nÄmelÄst_ nÄmeemÄilg enderip_Äd dress
idfir st_nÄmelÄst_ nÄmeemÄilg enderip_Äd dress
1CedS inkinscsinki ns0@php.ne tMÄle226.2 34.216.15
`;
const replacerMethod2 = (content, replacChar) => {
let newContent = content;
const specialChar =
['~', '!', '@', '#', '$', '%', '^', '&',
'*', '(', ')', '_', '+', '=', '-', '`',
'<', '>', '?', '/', '.', ',', '{', '}',
'[', ']', ':', '\"', '|', ';', '\'', '\\', '\/'];
newContent = newContent.replace(new RegExp(specialChar.join('|\\'), 'g'), '');
newContent = newContent.replace(
new RegExp(Object.keys(replacChar).join('|\\'), 'g'), match => (
replacChar[match]
));
return newContent;
};
const indexAction = () => {
const replacChar = {
Ä: 'a',
Ü: 'u',
Ö: 'o',
' ': '-'
};
return replacerMethod2(string, replacChar);
};
console.log(indexAction());
</script></body>
</html>
const string = `idfir st_nÄmelÄst_~!@#$%^&*()_+=-\`<>?/.,{}[]:"|;'\"nÄmeemÄilg enderip_Äd dress idfir st_nÄmelÄst_ nÄmeemÄilg enderip_Äd dress
idfir st_nÄmelÄst_ nÄmeemÄilg enderip_Äd dress
1CedS inkinscsinki ns0@php.ne tMÄle226.2 34.216.15
`;
const replacerMethod2 = (content, replacChar) => {
let newContent = content;
const specialChar =
['~', '!', '@', '#', '$', '%', '^', '&',
'*', '(', ')', '_', '+', '=', '-', '`',
'<', '>', '?', '/', '.', ',', '{', '}',
'[', ']', ':', '\"', '|', ';', '\'', '\\', '\/'];
newContent = newContent.replace(new RegExp(specialChar.join('|\\'), 'g'), '');
newContent = newContent.replace(
new RegExp(Object.keys(replacChar).join('|\\'), 'g'), match => (
replacChar[match]
));
return newContent;
};
const indexAction = () => {
const replacChar = {
Ä: 'a',
Ü: 'u',
Ö: 'o',
' ': '-'
};
return replacerMethod2(string, replacChar);
};
console.log(indexAction());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment