如果帐户已过期,请删除帐户详细信息

如果帐户已过期,请删除帐户详细信息

我需要什么正则表达式delete all the expired accounts

Name: John Smith
Address: 123 Sample Road
Country: England
Membership Expires: January 26, 2023, 9:35 am -288 Days
Plan: Platinum
Payment Method: American Express


Name: Paul Mitchell
Address: 911 Unknown Road
Country: USA
Membership Expires: October 7, 2024, 10:23 am 331 Days
Plan: Gold
Payment Method: Visa


Name: David Beckham
Address: 666 Example Road
Country: Scotland
Membership Expires: August 30, 2023, 6:03 pm -72 Days
Plan: Silver
Payment Method: Mastercard


Name: Frank Bruno
Address: 999 Random Road
Country: France
Membership Expires: April 19, 2024, 10:41 pm 160 Days
Plan: Bronze
Payment Method: PayPal

我想要的是:

Name: Paul Mitchell
Address: 911 Unknown Road
Country: USA
Membership Expires: October 7, 2024, 10:23 am 331 Days
Plan: Gold
Payment Method: Visa


Name: Frank Bruno
Address: 999 Random Road
Country: France
Membership Expires: April 19, 2024, 10:41 pm 160 Days
Plan: Bronze
Payment Method: PayPal

谢谢

答案1

  • Ctrl+H
  • 找什么:^Name:(?:(?!Name:|-).)+-\d+ Days(?:(?!Name:|-).)+(?=Name:|\z)
  • 用。。。来代替:LEAVE EMPTY
  • 打钩 相符
  • 打钩 环绕
  • 选择 正则表达式
  • 打钩 . matches newline
  • Replace all

解释:

^                       # beginning of line
Name:                   # literally
(?:(?!Name:|-).)+       # 1 or more any character but not "Name:" or "-"
-\d+                    # minus followed by 1 or more digits
 Days
(?:(?!Name:|-).)+       # 1 or more any character but not "Name:" or "-"
(?=Name:|\z)            # positive lookahead, make sure we have after: "Name:" or end-of-file

截图(之前):

在此处输入图片描述

截图(之后):

在此处输入图片描述

演示与说明

相关内容