Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 696 Bytes

Match.md

File metadata and controls

37 lines (25 loc) · 696 Bytes

Match

Example#1

import JStr from "@akcybex/jstr";

const pattern = /(\d{4})-(\d{2})-(\d{2})/g;
const subject = "The date is 2024-01-15";

const result = JStr.match(pattern, subject);
console.log(result); // Outputs: '2024-01-15'

Example#2

import JStr from "@akcybex/jstr";

const pattern = /(ab)*c/gi;
const subject = "ababcabab";
const result = JStr.match(pattern, subject);

console.log(result); // Outputs: 'ababc'

Example#3

import JStr from "@akcybex/jstr";

const pattern = /hello/;
const subject = "hello, world!";
const result = JStr.of(subject).match(pattern).toString();

console.log(result); // Outputs: 'hello'