Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

regex.match

const paragraph = 'The quick brown fox jumps over the lazy dog. It barked.';
const regex = /[A-Z]/g;
const found = paragraph.match(regex);

console.log(found);
// expected output: Array ["T", "I"]
Comment

match regex

const regex = /([a-z]*)ball/g;
const str = "basketball football baseball";
let result;
while((result = regex.exec(str)) !== null) {
	console.log(result[1]); 
    // => basket
    // => foot
    // => base
}
Comment

regex exact match

use ^ and $ to match the start and end of your string
^matchmeexactly$
Comment

string.regex match

const str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
const regexp = /[A-E]/gi;
const matches_array = str.match(regexp);

console.log(matches_array);
// ['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e']
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord bot remove message reaction 
Javascript :: Automatic Slideshow in react js 
Javascript :: give a prop only if pass condition 
Javascript :: wait until 
Javascript :: What is array.push in javascript 
Javascript :: create video playlist using jquery 
Javascript :: javascript do while array 
Javascript :: scroll up link 
Javascript :: date range npm 
Javascript :: mdn trim 
Javascript :: Accessing user input through js 
Javascript :: javascript integer to binary 
Javascript :: address format json 
Javascript :: form contact 7 ajax send 
Javascript :: jquery if else click function 
Javascript :: exec in node js 
Javascript :: moment duratuion from hours 
Javascript :: sort array based on multiple columns javascript 
Javascript :: How can i change Header Bar height in react native 
Javascript :: js 1 minute sleep 
Javascript :: fill array javascript 
Javascript :: for loop react 
Javascript :: chrome extension catch shortcut 
Javascript :: js rename onclick function 
Javascript :: first n elements of array js 
Javascript :: for of and for in javascript 
Javascript :: javascript global function 
Javascript :: lunix increae ram available to nodejs 
Javascript :: filter in javascipt 
Javascript :: feet to km js 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =