본문 바로가기

코딩?

정규표현식_연습_regexone_practice

 

https://regexone.com/lesson/letters_and_digits? 

 

RegexOne - Learn Regular Expressions - Lesson 1½: The 123s

Characters include normal letters, but digits as well. In fact, numbers 0-9 are also just characters and if you look at an ASCII table, they are listed sequentially. Over the various lessons, you will be introduced to a number of special metacharacters use

regexone.com

 

## 1. [0-9]+ : 연속된 숫자 매칭

. : 임의의 문자 하나

[abc] : 특정 문자 추출

[x-y] : 문자 범위를 이용한 추출

{m,n}  : 문자 갯수 범위를 이용한 추출

\ : 특수 문자는 \를 이용해서 문자 그대로 추출(escape)

숫자, 점(.), 공백, 영어 소문자가 섞인 문자 추출하기 -> regex = '\d\.\s+[a-z]+'

^...S : 문자열의 시작(^)과 끝($) 지정해서 문자 추출

(a(bc)) : Capture - Sub-group

(abc|def) : Matches abc or def