What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-09-01 00:17:02
nl2br javascript
function nl2br (str, is_xhtml) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Philip Peterson // + improved by: Onno Marsman // + improved by: Atli Þ&oacut... Add solution -
Javascript 2021-08-31 23:09:02
javascript format number as currency
const formatToCurrency = amount => { return "$" + amount.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, "$&,"); }; formatToCurrency(12.34546); //"$12.35" formatToCurrency(42345255.356); //"$42,345,255.36 Add solution -
Javascript 2021-08-31 22:39:02
if text is in curly braces replace to div site:stackoverflow.com
function getParams(input){ var matches = []; input.replace(/(\{+)([^}]+)(}+)/g,function(orig,lb,txt,rb){ if (lb.length === rb.length) matches.push(txt); }); return matches; } var string = "<div>{{foo}} and {{{bar}}} and {{... Add solution -
Javascript 2021-08-31 18:12:01
replace all swear words using bookmarklet
javascript:function htmlreplace(a,b,element){if(!element)element=document.body;var nodes=element.childNodes;for(var n=0;n<nodes.length;n++){if(nodes[n].nodeType==Node.TEXT_NODE){nodes[n].textContent=nodes[n].textContent.replace(new RegExp(a,'gi'),b);}e... Add solution -
Javascript 2021-08-31 16:35:03
how to erase spaces from a string javascript
str.replace(/\s+/g, '') Add solution -
Javascript 2021-08-31 08:11:02
remove whitespace with regex javascript
return str.replace(/\s/g, ''); Add solution -
Python 2021-08-30 19:18:02
word search puzzle python
An improved (shorter, more efficient) version of the above: #!/usr/bin/python # -*- coding: utf-8 -*- puzzle='''F Y Y H N R D R L J C I N U A A W A A H R N T K L P N E C I L F S A P E O G O T P N H P O L A N D ''' clues = ['ITALY', 'HOLLAND'... Add solution
Best helpers
Ranking is empty