“Regex cocok” Kode Jawaban

Regex cocok dengan string yang tepat

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*
Tomas Maillo

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"]
Gil Reich

Cocokkan 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
}
ali ahmed

Regex cocok

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

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']
Vast Vendace

Jawaban yang mirip dengan “Regex cocok”

Pertanyaan yang mirip dengan “Regex cocok”

Lebih banyak jawaban terkait untuk “Regex cocok” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya