보면 자연스레 문자열 교체도 자주 하게 되는데, 정규표현식에는 문자열 교체에 필요한 기능도
들어 있습니다. 예를 들어 이메일 주소처럼 보이는 문자열을 찾아 그 주소를 가리키는 하이퍼
링크로 바꿀 수 있습니다.
정규표현식을 소개한 책이나 문서를 보면 “
aaaba
와
abaaba
에 일치하지만
abba
에는 일치하
지 않는 문자열” 같은 이상야릇한 예제가 많이 보입니다. 물론 이런 예제는 정규표현식의 복잡
함을 이해하기 쉬운 덩어리로 나눈다는 장점이 있긴 하지만, 그만큼 현실성이 없다는 단점도
있습니다. 대관절
aaaba
에 일치하는 문자열을 찾아서 어디 쓴단 말입니까? 필자는 정규표현식
의 기능을 설명하면서 바로 쓸 수 있는 현실적인 예제를 사용하려고 합니다.
정규표현식은 정규식이라고 부르기도 합니다. 앞으로는 정규식이라고 간단하게 쓰겠습니다.
17.1
부분 문자열 검색과 대체
정규식으로 하는 일은 결국 문자열 속에서 부분 문자열을 찾는 일이며 찾은 부분을 교체할 때
도 있습니다. 정규식이 제공하는 기능은 대단히 유연하고 강력하지만 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.