Alex Rees
Alex Rees

Reputation: 35

Find and replace in Notepad++ matching beginning and end of line

I would like to find all lines that follow this format:

type="file_one_id"
type="file_two_id"
type="file_three_id"

And replace them with a single replacement line:

type="my_generic_replacement"

The problem is that there are many other lines which also start with type="file_ or end with _id" , so I'm thinking that searching for lines that both begin with type="file_ and end with _id" will be required. Is there a way to do this with notepad++?

Upvotes: 2

Views: 4300

Answers (3)

Keith H
Keith H

Reputation: 25

You can find and replace \r\n and tick Extended in the Replace box; \r\n matches carriage-return + line-feed. Some systems may only have \r or only \n at the line breaks

Upvotes: 0

Andie2302
Andie2302

Reputation: 4887

To replace the lines in Notepad++ you can use this regex:

type="file_\w+_id"

To open the window click Search => Replace

enter image description here

Upvotes: 1

Sebastian Proske
Sebastian Proske

Reputation: 8413

You could search for ^type="file_.*_id"$ (using Regular Expressions) and replace with type="my_generic_replacement"

Upvotes: 5

Related Questions