What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-17 00:49:18
count word and space in text javascript
<html> <body> <script> function countWords(str) { str = str.replace(/(^\s*)|(\s*$)/gi,""); str = str.replace(/[ ]{2,}/gi," "); str = str.replace(/\n /,"\n"); return str.split(' ').length; }... Add solution -
Rust 2021-11-13 02:56:14
regex to find and replace values
str = str.replace(/[^a-z0-9-]/g, ''); /* Everything between the indicates what your are looking for / is here to delimit your pattern so you have one to start and one to end [] indicates the pattern your are looking for on one specific character... Add solution -
Javascript 2021-11-12 02:17:12
escape in javascript
function escapeHtml(str) { return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;"); } Add solution -
Javascript 2021-11-09 17:32:08
filter a query string with comparison operator
//if need to find ratings greater then 3 //The query string may be: //127.0.0.1:8000/api/v1/posts?ratings[gt]=3 //if we check the req.query //{ ratings: { gt: '3' } } exports.getPosts = async (req, res) => { try { const queryObj = { ...req.query ... Add solution
Best helpers
Ranking is empty