replace & replaceAll
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
replace("a", "b") zëvendëson vetëm të parin; replaceAll() të gjithë. Me regex dhe flamurin g, replace(/a/g, "b") bën të njëjtën gjë.
EnglishEN
replace("a", "b") replaces only the first one; replaceAll() replaces all. With a regex and the g flag, replace(/a/g, "b") does the same.
Si ta mendosh
Si „gjej dhe zëvendëso“ në Word: një herë ose të gjitha.
Lexoje në anglisht
Like Word's “find and replace”: once or all.
Shembull kodijavascript
"a-b-c".replace("-", " "); // "a b-c"
"a-b-c".replaceAll("-", " "); // "a b c"