Wikipedia anchor

Published on Tue Mar 01 2022

Match Wikipedia anchor dot-instead-of-percent encoding string.replace(/((?:\.[a-f0-9]{2}){2})/ig, function(match) { return decodeURIComponent(match.replace(/\./g, '%')) });

Additional matching regexes for
Wikipedia anchor

Wikipedia anchor

Match Wikipedia anchor dot-instead-of-percent encoding string.replace(/((?:\.[a-f0-9]{2}){2})/ig, function(match) { return decodeURIComponent(match.replace(/\./g, '%')) });

Title Casing

for use in function to title case a string; function cap(str) { return str.replace(/\w\S*/g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); }

regex to get N words from a line

usefull if you want to return (N) words instead of (N) chars

Links in string

Match links (emails included) in string Replace it with HTML links

lisp

match function names in defun constructs

get file Extensions

var fileExtensionPatter = /\.([0-9a-z]+)(?=[?#])|(\.)(?:[\w]+)$/ var ma1 = 'css/global.css?v=1.2'.match(fileExtensionPatter)[0]; console.log(ma1); // return .css var ma2 = 'index.html?a=param'.match(fileExtensionPatter)[0]; console.log(ma2); // return .html var ma3 = 'default.aspx?'.match(fileExtensionPatter)[0]; console.log(ma3); // return .aspx var ma4 = 'pages.jsp#firstTab'.match(fileExtensionPatter)[0]; console.log(ma4); // return .jsp var ma5 = 'jquery.min.js'.match(fileExtensionPatter)[0]; console.log(ma5); // return .js var ma6 = 'file.123'.match(fileExtensionPatter)[0]; console.log(ma6); // return .123

Function Declaration / Expression

matches both function declarations and expressions in javascript. ex. function name () {...} || function () {}

Arrow function to Normal function

Convert Arrow Function to Normal Function

Replace \n by <br />

Replace non-ending string \n by the <br /> HTML tag

replace-last-comma with semicolon

replace-last-comma with semicolon similar to http://stackoverflow.com/questions/3829483/how-to-replace-last-occurrence-of-characters-in-a-string-using-javascript