Page 1 of 1

Replace a single regular

Posted: Mon May 07, 2012 6:02 am
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.

Re: Replace a single regular

Posted: Mon May 07, 2012 9:35 pm
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