Upon posting this question, I learn that it is mandatory, whenever testing/playing with regexes, to make sure you are using an environment that follows/matches the Regular Expression behavior of the language you are programming with.
Otherwise things will not make sense.
Check this for online sandboxes for regex testing, per programming language.
Keeping track of interesting places I put my feet on in the software development world.
Search This Blog
Monday, December 28, 2015
Wednesday, December 16, 2015
Nuget Helpers Package
Uploaded a nuget package containing methods I have been using very often in new projects.
Below is a list of all methods provided at this point:
Nuget install command: Install-Package Helpers
Below is a list of all methods provided at this point:
Nuget install command: Install-Package Helpers
Sunday, December 13, 2015
Enforcing a given number of digits in a numeric value in Javascript
Javascript does not a built-in functionality like C#'s .ToString("0000").
To accomplish the same I came up with the following:
function setNumericFormat(value, numOfDigits, paddingChar) {
var length = value.toString().length;
if (length < numOfDigits) {
var prefix = "";
for (var i = 1; i <= numOfDigits - length; i++) {
prefix += paddingChar;
}
return prefix + value.toString();
}
return value.toString();
}
Resembles a LeftPad function...
To accomplish the same I came up with the following:
function setNumericFormat(value, numOfDigits, paddingChar) {
var length = value.toString().length;
if (length < numOfDigits) {
var prefix = "";
for (var i = 1; i <= numOfDigits - length; i++) {
prefix += paddingChar;
}
return prefix + value.toString();
}
return value.toString();
}
Resembles a LeftPad function...
Subscribe to:
Posts (Atom)