سؤال

I need to delete all lines on a file non starting by "07". I already try a lot of regular expressions without success. can someone pleas ehelp me with this?

هل كانت مفيدة؟

المحلول

The regex is

^(?!07).*$

using the g (global) and m (multiline) flags. Search on that and replace with nothing.

Link with explanation:

  • The ^ asserts "beginning of line" (because we used the m modifier).

  • The (?!07) means "not starting with 07". It's called a "negative look-ahead".

  • The .* means "zero or more of anything".

  • The $ means "end of line" (because we used the m modifier).

  • The g modifier means "globally" (all occurrences).

I haven't used Notepad++, but the docs say it uses PCRE, so the above should work. If it expects you to write the expression and flags all together, that would most likely be:

/^(?!07).*$/gm

نصائح أخرى

Just do this:

^(?!07).*

and replace with nothing.

You don't need $ because .* stops at new line.

i think you can use a match like this

/^(0[^7]).*/gm

in this case it will match for any number but not 7

since [07] will match for 0 or 7 not both

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top