Thomas Reese
Thomas Reese

Reputation: 1

Remove Numbers in the first 1-3 spaces in Notepad++

A very similar issue to Remove Numbers in Notepad++

Except in my case I wish to only delete the bold numbers in front.

As far as I know, the only regex I know how to use for this deletes all numbers in a text file, however I need the middle three numbers kept.

Here is an excerpt from a file that has thousands of similar lines.

9;0;4;248;sea;false;ocean;0

13;0;8;244;sea;false;ocean;0

489;0;10;232;sea;true;ocean;0

How can I delete the first numbers that have 1-3 characters without deleting the numbers in between the semi colons?

Upvotes: 0

Views: 1357

Answers (3)

The fourth bird
The fourth bird

Reputation: 163277

To match the first 1-3 digits you could use ^\d{1,3}.

If you only want to match those followed by a semicolon you could add a positive lookahead (?=;) to assert what follows is a semicolon.

^\d{1,3}(?=;)

Instead of a positive lookahead you could also match ^\d{1,3} followed by capturing the semicolon in a capturing group (;) and in the replacement use group 1.

^\d{1,3}(;)

Upvotes: 1

Leogao
Leogao

Reputation: 314

using the following regular expression to match then replace them to empty, it seems to work for you to delete the first numbers that have 1-3 characters

^\d{1,3}

Upvotes: 1

user939857
user939857

Reputation: 395

regular expressions seem to work so from "^[\d]*;" to "" without the quotes will strip all leading digits and the first semicolon

Upvotes: 0

Related Questions