Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Find and Replace multiple digits with the last character in notepad++

Does anyone know how to replace several different Digits all at once in notepad++.

For example, I have 4 different Digits;

1000x1000.jpg
750x750.jpg
1000x750.jpg
750x1000.jpg

I want the result like this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

1000x1000.jpg 1000
650x550.jpg 650
1200x850.jpg 1200
350x1300.jpg 350

I was trying to select each first digit and make them in groups with this Regex:

([0-9]{4}x+[0-9]{4}.jpg)|([0-9]{3}x+[0-9]{4}.jpg)|([0-9]{3}x+[0-9]{3}.jpg)|([0-9]{4}x+[0-9]{3}.jpg)

But I can’t replace them after .jpg

>Solution :

You can use

^(\d+)x\d+\.jpg$

Replace with $0 $1.

See the regex demo. Details:

  • ^ – start of string
  • (\d+) – Group 1 ($1): one or more digits
  • x – an x char
  • \d+ – one or more digits
  • \.jpg – a .jpg string
  • $ – end of string (line here, in Notepad++).

Note that $0 is a backreference to the whole match value. $1 refers to Group 1 value.

Regex variations

If the match does not fit the whole line, use either word (\b(\d+)x\d+\.jpg\b) or numeric/word ((?<!\d)(\d+)x\d+\.jpg\b) boundaries.

See demo:

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading