이메일:비밀번호만 유지하는 정규식

이메일:비밀번호만 유지하는 정규식

이메일과 비밀번호만 유지하고 다른 정보는 모두 삭제하고 싶습니다.

Name: Test1 Test1
Address: 11 Test Road
Country : Test1
Post Code: abc111
EmailPass : [email protected]:password111$£*!


Name: Test2 Test2
Address: 22 Test Road
Country : Test2
Post Code: abc222
EmailPass : [email protected]:password222$£*!

내가 원하는 것:

[email protected]:password111$£*!
[email protected]:password222$£*!

답변1

이메일과 일치합니다.오직~ 후에EmailPass :

  • Ctrl+H
  • 무엇을 찾다:.+?EmailPass : (\S+@\S+)
  • 다음으로 교체:$1\n
  • 선택 취소 성냥갑
  • 확인하다 줄 바꿈
  • 확인하다 정규식
  • 확인하다 . matches newline
  • Replace all

설명:

.+?             # 1 or more any character, not greedy
EmailPass :     # literally
(               # group 1
    \S+             # 1 or more non space
    @               # @
    \S+             # 1 or more non space
)               # end group

대사:

$1      # content of group 1, the email
\n      # a linebreak, you can use \r\n for Windows EOL

스크린샷(이전):

여기에 이미지 설명을 입력하세요

스크린샷(이후):

여기에 이미지 설명을 입력하세요

답변2

이는 올바른 이메일( 양쪽과 사이의 텍스트를 포함하는 이메일) @만 일치합니다 . 또한 제공된 비밀번호가 있는지 .확인합니다 .:

(?s).*?(\S+@\S+\.\S+:\S+)|.+

다음으로 교체\1\n

입력 예:

Post Code: abc111
EmailPass : [email protected]:password222$£*!

Post Code: abc222
EmailPass : test_222@gmail.:password222$£*!

Post Code: abc111
EmailPass : [email protected]:

Post Code: abc111
EmailPass : [email protected]:password333$£*!

결과:

[email protected]:password222$£*!
[email protected]:password333$£*!

데모

관련 정보