Replace a single regular

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

Replace a single regular

Postby shveicar980 » Mon May 07, 2012 6:02 am

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: 2136
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Replace a single regular

Postby DataMystic Support » Mon May 07, 2012 9:35 pm

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
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 1 guest