1

What I need to do is to delete everything that ends with desktop.ini and begins with Library with varying text in between.

In my list, it looks like this:

Library\aaaa\desktop.ini
Library\bbbb\1111\desktop.ini
Library\bbbb\line-I-dont-want-to-delete
Library\cccc\222\CCCC\desktop.ini
Library\dddd\3333\D\desktop.ini

After using the Replace feature, all that should be left is:

Library\bbbb\line-I dont-want-to-delete.

I'm really terrible with RegEx, but what I need is something like this:

^Library\$[(A-Z)?]\desktop.ini

Apologies if that's all I have, but thanks in advance for helping me with this!

1
  • A shortest possible code can be ^lib.*ini\n so that you not forget it soon next time ...... Commented Oct 12, 2021 at 2:57

1 Answer 1

2

You can use

Find What:    ^Library\\(?:.*\\)?desktop\.ini$\R?
Replace With: <empty>

Details:

  • ^ - start of string
  • Library\\ - Library\ string
  • (?:.*\\)? - an optional non-capturing group matching zero or more chars other than line break chars as many as possible and then a \ char
  • desktop\.ini - a desktop.ini string
  • $ - end of line
  • \R? - an optional line break char (sequence).

See the demo below:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.