Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- isSquare
- type
- java api
- codewars
- JDBC
- Debug
- react hook
- DB2
- useEffect
- manifest.json
- react
- descendingOrder
- custom hook
- IBM
- TABLESPACE
- codewar
- TypeScript
Archives
- Today
- Total
taesik
isValidIP 본문
Number( sth )
can check it is number or string with only number.
if sth contains other, it would return Nan.
function isValidIP(str) {
return str .split('.')
.filter(v => v == Number(v).toString() && Number(v) >= 0 && Number(v) < 256)
.length == 4;
}
Examples of valid inputs:
1.2.3.4
123.45.67.89
1.2.3
1.2.3.4.5
123.456.78.90
123.045.067.089
'functions and trick > typescript_javascript' 카테고리의 다른 글
| is valid phone number (regex) (0) | 2022.01.26 |
|---|---|
| string replace using regex (0) | 2022.01.26 |
| makes this string uppercasegives it sorted in alphabetical order by last name. (0) | 2022.01.25 |
| Sum of numbers from 0 to N (0) | 2022.01.25 |
| how many times father see kid's falling and bouncing ball (0) | 2022.01.25 |