Network disconnected
Description
이번 시간에는 C#으로 정규표현식을 다루겠습니다.
C#으로 정규표현식을 다룰 때에는 Regex.matches라는 메소드를 이용합니다.
주의할 점: C#에서는 \
대신 \\
를 적어야 합니다.
Python은 raw string을 지원해 대표 문자1를 표현할 때 역슬래시 \
를 한 번만 쓸 수 있습니다. 허나, C#에서는 escape 때문에 역슬래시를 사용해 역슬래시 \
를 두 번 적어야 합니다.
빈칸에 \\d
를 입력하고 [실행]해 보세요. Output으로 search_target에 들은 모든 숫자가 한 줄씩 나올 겁니다.
-
\d
,\w
등 ↩
Question type: Fill in the blank
- You need to fill in the blank with the appropriate code.
- You cannot modify the given code.
- An error message will appear in the result if you leave the blank empty.
1
2
3
4
5
6
7
8
9
10
11
12
13
using System;
using System.Text.RegularExpressions;
public class RegexTest {
public static void Main() {
string regex = "";
string searchTarget = "Luke Skywarker 02-123-4567 luke@daum.net\n다스베이더 070-9999-9999 darth_vader@gmail.com\nprincess leia 010 2454 3457 leia@gmail.com";
foreach (Match m in Regex.Matches(searchTarget, regex)){
Console.WriteLine(m.Value);
}
}
}
Result
Stop
Result of [Run Test] or [Submit] will be displayed here
내가 제출한 코드가 왜 틀렸는지 프로그래머스 AI에게 물어보세요.
제출 후 채점하기를 눌러 30점 이상인 경우 물어볼 수 있어요.
베타 기간 동안에는 한 문제당 1번만 물어볼 수 있어요.
베타 기간 동안에는 한 문제당 1번만 물어볼 수 있어요.