2024-06-21
This commit is contained in:
30
Writerside/topics/Regular-Expression.md
Normal file
30
Writerside/topics/Regular-Expression.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# 정규표현식
|
||||
|
||||
```javascript
|
||||
let regex = /[a-z0-9]*/;
|
||||
let regex = new RegExp("[a-z0-9]*");
|
||||
let regex = /[a-z0-9]*/g;
|
||||
let regex = new RegExp("[a-z0-9]*", "g");
|
||||
```
|
||||
|
||||
```javascript
|
||||
exec(str) // 결과를 배열로 반환합니다. 일치하지 않으면 null을 반환합니다.
|
||||
test(str) // 결과를 true 또는 false로 반환합니다.
|
||||
```
|
||||
|
||||
```javascript
|
||||
let regex = /(\w+)\s(\w+)/;
|
||||
|
||||
let result = regex.exec("stive jobs");
|
||||
console.log(result);
|
||||
/*
|
||||
[
|
||||
'stive jobs',
|
||||
'stive',
|
||||
'jobs',
|
||||
index: 0,
|
||||
input: 'stive jobs',
|
||||
groups: undefined
|
||||
]
|
||||
*/
|
||||
```
|
||||
Reference in New Issue
Block a user