L
L
lumb2018-08-21 11:23:58
Regular Expressions
lumb, 2018-08-21 11:23:58

How to add and remove parts of a string using a regular expression?

There are lines like

(37, '2011-01/1295144032_x_7cb0bcf1.jpg|||2011-01/1295266037_small_carterthal1.jpg.jpg|||2014-05/1401429739_3-fundamenta-vidyatshih2.jpg', 66),
(38, '2011-01/1295266433_event-image-poster.jpg|||2011-01/1295279508_16f7cb40.jpg', 67),
(39, '2012-01/1295277340_1.jpg|||2011-01/1295278172_08a9e04f4264-300x298.jpg|||2014-05/1401428634_vladislav-erko-castaneda-9.jpg', 68),

You need to add "upload/" after the first apostrophe and remove everything after ||| before the closing apostrophe (including |||)
to get
(37, 'upload/2011-01/1295144032_x_7cb0bcf1.jpg', 66),
(38, 'upload/2011-01/1295266433_event-image-poster.jpg', 67),
(39, 'upload/2012-01/1295277340_1.jpg', 68),

I'm using Notepad++ and nothing works so far

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-08-21
@lumb

(\(\d+), '(.*?)[|]{3}.*?', (\d+\),?)
replace with
https://regex101.com/r/KLYCxe/2
(\(\d+), '(.*?)(?:[|]{3}.*?)?', (\d+\),?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question