Delete everything after the twelth character in a line with other lines of text that need to be left alone
-
So my text is something like this:
thing 000001(text to be deleted) don't touch this line not this one either thing 000002(text to be deleted) nope nada nowhere no how thing 000003(text to be deleted) you get the idea
Basically I want it to delete everything after the twelfth character on lines starting with “thing” and followed by a number that goes up in sequential order, while leaving the other lines alone.
Currently I’m using this code, which works well enough but is obviously not a one click solution, and I’ve got many hundreds, if not thousands of lines to go through.
Find: ^(.{12}).*$ Replace: \1
Is there a way to add to this code that tells it to only look for lines that start with “thing”+number and then delete everything after 12 characters?
-
@freshenstein said in Delete everything after the twelth character in a line with other lines of text that need to be left alone:
Is there a way to add to this code that tells it to only look for lines that start with “thing”+number and then delete everything after 12 characters?
Possibly as long as the number is a consistent length, you would change your formula to something like
^(thing \d{6})
. Doing it this way you need to limit to an exact character count, so the number must ALWAYS be 6 characters long.Alternatively something like
^(thing \d+)
will work. So it works up until the end of the number. This could be 12 characters, or more or less. The\d+
means as many digits that are together, but must be at least 1.Terry
PS understand I’m only editing the first part of your regular expression. It’s up to you to add in the “rest of the line” or whatever else you intend to do.