Created
June 5, 2017 22:22
-
-
Save devlifeX/a6c8ebc94dd5b2171c499c3c6432370c to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/gezadal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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