JS - Other

RegExp (Quantifiers)

n+

Matches any string that contains at least one n


n*

Matches any string that contains zero or more occurrences of n


n?

Matches any string that contains zero or one occurrences of n


n{X}

Matches any string that contains a sequence of X n's


n{X,Y}

Matches any string that contains a sequence of X to Y n's


n{X,}

Matches any string that contains a sequence of at least X n's


n$

Matches any string with n at the end of it


^n

Matches any string with n at the beginning of it


?=n

Matches any string that is followed by a specific string n


?!n

Matches any string that is not followed by a specific string n

RegExp Object Methods

compile()

Deprecated in version 1.5. Compiles a regular expression


exec()

Tests for a match in a string. Returns the first match


test()

Tests for a match in a string. Returns true or false


toString()

Returns the string value of the regular expression

RegExp Object Properties

constructor

Returns the function that created the RegExp object's prototype


global

Checks whether the "g" modifier is set


ignoreCase

Checks whether the "i" modifier is set


lastIndex

Specifies the index at which to start the next match


multiline

Checks whether the "m" modifier is set


source

Returns the text of the RegExp pattern

Regular All Falsy Value From Array

array.filter(Boolean);

array.filter(x => x == 'x');

Regular Expressions Testing

/searchString/i.test('string');

Remove All Text Before/After Certain Point

To remove everything before first /

input = input.Substring(input.IndexOf("/"));


To remove everything after first /

input = input.Substring(0, input.IndexOf("/")+1);


To remove everything before last /

input = input.Substring(input.LastIndexOf("/"));


To remove everything after last /

input = input.Substring(0, input.LastIndexOf("/")+1);

Reorder S/N Number before/after Table Row add/delete

$('table tbody tr td:first-child').children('span').text(function (i) {
 return i + 1;
});

Replace All

string.replace(/string/g, 'string');

Reset Form

$("form").reset();

Resize an Array

array.length = num;

Reverse A String

string.split('').reverse().join('');

Rounds A Number DOWNWARDS To The Nearest Integer

Math.floor(number)