2

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:

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

EnigmaOs
  • 25
  • 4

2 Answers2

2

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

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
0

I would like to add humbly previously posted code. Because just added "concat" function and simple code.

 select col,concat(col,regexp_replace(col,'^(\d+)x(\d+)\.jpg','\1')) as c from 
(   select '1000x1000.jpg ' as col from dual union all
    select '650x550.jpg ' as col from dual union all
    select '1200x850.jpg ' as col from dual union all
    select '350x1300.jpg ' as col from dual
)
Motif
  • 69
  • 9