Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

regex match exact string

you want to achieve a case insensitive match for the word "rocket" 
surrounded by non-alphanumeric characters. A regex that would work would be:

W*((?i)rocket(?-i))W*
Comment

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 :: javascript example 
Javascript :: js run npm 
Javascript :: react switch case 
Javascript :: create array of numbers javascript 
Javascript :: jquery alertify 
Javascript :: using plice to remove an element from an array in react 
Javascript :: react-beforeunload react navive 
Javascript :: bubbling and capturing in javascript 
Javascript :: getting cannot call a class as a function 
Javascript :: start button js 
Javascript :: array last element 
Javascript :: apartments api 
Javascript :: react hook form example stack overflow 
Javascript :: Animated Sticky Header 
Javascript :: angular formatting numbers with -commas 
Javascript :: java script or js circle collision 
Javascript :: currency conversion to locale string js 
Javascript :: update state in useState hook 
Javascript :: create window electron 
Javascript :: how to check for null in javascript 
Javascript :: how to use cros 
Javascript :: invertir un array javascript 
Javascript :: object loop 
Javascript :: node query selector 
Javascript :: Vowel Count 
Javascript :: jquery dialog modal on modal 
Javascript :: how to get current time using moment 
Javascript :: Showing a custom toast function for react-toastify - Toast show 
Javascript :: browserrouter invalid hook call 
Javascript :: linear search javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =