Bạn refers theo Regex syntax guideline này:
https://www.cplusplus.com/reference/regex/ECMAScript/
Một số từ khoá cho bạn tìm kiếm ở trong guideline:
“4 kí tự đầu tiên trong chuổi”, “3 con số cuối cùng”
characters |
description |
condition for match |
^ |
Beginning of line |
Either it is the beginning of the target sequence, or follows a line terminator. |
$ |
End of line |
Either it is the end of the target sequence, or precedes a line terminator. |
“hết kí tự abc”
characters |
description |
matches |
\w |
word |
an alphanumeric or underscore character (same as [_[:alnum:]] ). |
\W |
not word |
any character that is not an alphanumeric or underscore character (same as |
characters |
times |
effects |
* |
0 or more |
The preceding atom is matched 0 or more times. |
+ |
1 or more |
The preceding atom is matched 1 or more times. |
“liên kết chử và số”
characters |
description |
effects |
(subpattern) |
Group |
Creates a backreference. |
Sau đó thì chạy 1 vòng lặp for để đổi lowercase sang uppercase.
Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.