
특정 데이터 요소를 추출해야 하는 텍스트 파일이 있습니다.
예시 텍스트:
안녕ABK>Z48812~HIAPR>Z48812~HI*ABF>I2510*ABF>K810*ABF>I10*ABF>J449*ABF>F329*ABF>F419*ABF>I252~NM1*71*1*다르비니안*세바크****XX*1306859178 ~LX*1~SV2*0551*HC>G0154*250*UN*4~DTP*472*D8*20180202~REF*6R*74990814~HL*3*1*22*0~HIABK>N390~HIAPR>N390~HI*ABF>B9620*ABF>B961*ABF>N319*ABF>G8220*ABF>S12300S*ABF>G9520*ABF>Z1612~NM1*71*1*Boonyaputthikul*Robert****XX*1700198801 ~LX*1~SV2*0551*HC>G0154*250*UN*4~DTP*472*D8*20180125~REF*6R*74990810~
나는 다음을 추출하고 싶다:
다르비니아 세바크 1306859178
Boonyaputthikul 로버트 1700198801
notepad++로 어떻게 할 수 있나요?
답변1
Notepad++에서는 이 작업을 한 번에 수행할 수 없습니다. 다음과 같이 할 수 있습니다.
첫 번째 단계:
- Ctrl+H
- 무엇을 찾다:
(?:^|\G).+?NM1\*71\*1\*(.+?)\*{4}XX\*(\d+)
- 다음으로 교체:
$1 $2\n
- 둘러보기 확인
- 정규식 확인
- 확인하지 마세요
. matches newline
- Replace all
설명:
(?: : non capture group
^ : beginning of line
| : R
\G : position of last match
) : end group
.+? : 1 or more any character, not greedy
NM1\*71\*1\* : literally "MN1*71*1*", asterisk have to be escaped
(.+?) : group 1, 1 or more any character, not greedy
\*{4}XX\* : 4 asterisks, XX, then 1 asterisk
(\d+) : group 2, 1 or more digit
대사:
$1 : content of group 1
: a space
$2 : content of group 2
\n : line feed, you could change it for the linebreak you need
주어진 예에 대한 결과:
Darbinian*Sevak 1306859178
Boonyaputthikul*Robert 1700198801
LX*1~SV2*0551*HC>G0154*250*UN*4~DTP*472*D8*20180125~REF*6R*74990810~
두 번째 단계에서는 마지막 줄을 삭제해야 합니다.