js regex match first 3 characters in string
JavaScript[Edit]
+
0
-
0
js regex match first 3 characters in string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15const expression = /^.{3}/; // Usage example: const text = '123Example'; const result = text.match(expression); if (result) { console.log(result); // ['123'] } // ^ matches the beginning of the string // . matches any character except line breaks // {3} matches 3 of preceding token (matches 3 .)