Regular expressions in JavaScript
Në shqip: Shprehjet e rregullta në JS
ShpjegimiSQ
Në JS, regex-i shkruhet mes / / me flamuj si g (të gjitha), i (pa dallim shkronjash), u (unicode). test() kthen true/false, match() dhe matchAll() gjejnë përputhjet.
EnglishEN
In JS, a regex is written between / / with flags like g (all), i (case-insensitive), u (unicode). test() returns true/false, match() and matchAll() find the matches.
Si ta mendosh
Si një sitë që lë të kalojë vetëm ajo që të duhet.
Lexoje në anglisht
Like a sieve that lets through only what you need.
Shembull kodijavascript
const email = /^[^@\s]+@[^@\s]+\.\w+$/;
email.test("arta@shkolla.al"); // true
"a1b22".match(/\d+/g); // ["1", "22"]