Replace a single regular

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
shveicar980
Posts: 11
Joined: Thu Apr 26, 2012 11:57 pm

Replace a single regular

Post by shveicar980 »

Hello,
Tell me how I can replace a single regular expression other
a simple regular expression. I have got an example, a text file with lines

Code: Select all

G:/1/gusi_lebedi/gisi_lebedi1.htm
G:/1/guravlj_tsaplja/guravlj_tsaplja.htm
G:/1/gribok_teremok/gribok_teremok.htm
mask of search:

Code: Select all

G:/([^"]+)/([^"]+)/([^"]+).htm
mask of replace:

Code: Select all

G:/$1/$2/
Finally I get desired option for me

Code: Select all

G:/1/gusi_lebedi/
G:/1/guravlj_tsaplja/
G:/1/gribok_teremok/
If the number of directory changes then it must have a different lenghth

Code: Select all

G:/1/gusi_lebedi/../../gisi_lebedi1.htm
G:/1/guravlj_tsaplja/guravlj_tsaplja.htm
G:/1/gribok_teremok/../../../gribok_teremok.htm
mask of search: ? mask of replace: ?
then this filter should be changed each time
Have you got scheme of a regular expression that will allow
get this, same result

Code: Select all

G:/1/gusi_lebedi/
G:/1/guravlj_tsaplja/
G:/1/gribok_teremok/
does not depend on the number of
directories in the chain.
Thank you.
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Replace a single regular

Post by DataMystic Support »

Just use Filters\Replace\Find pattern (perl style)

Change search from G:/([^"]+)/([^"]+)/([^"]+).htm to:

Code: Select all

([^"]+)/([^"]+)/([^"]+).htm
and replace from: G:/$1/$2/ to:

Code: Select all

$1/$2
Post Reply