MRT - How to remove all characters after a string

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
Alexisback
Junior Member
Junior Member
Posts: 80
Joined: 2016-10-26, 20:04 UTC

MRT - How to remove all characters after a string

Post by *Alexisback »

Why doesn't this regular expression work? :?:
(?<=.jpg).*
I have to delete from a folder all the text after the end of the JPG

first
-_0qxe-yGro.jpg@size=960x720&quality=96&sign=25ff49e3eaba39ed3ca04908c6f779f4&type=album
after
-_0qxe-yGro.jpg
Image: https://www.upload.ee/image/13915581/sshot-1.png
User avatar
solid
Power Member
Power Member
Posts: 749
Joined: 2004-08-09, 11:20 UTC

Re: MRT - How to remove all characters after a string

Post by *solid »

Works at my place.

Just tick [E], and untick [Subst.] ([Sostituisci])

Although I'm not getting error in any case.
Alexisback
Junior Member
Junior Member
Posts: 80
Joined: 2016-10-26, 20:04 UTC

Re: MRT - How to remove all characters after a string

Post by *Alexisback »

It doesn't work, I receive error :roll:

Image: https://www.upload.ee/image/13915700/sshot-2.png
User avatar
Gral
Power Member
Power Member
Posts: 1600
Joined: 2005-01-26, 15:12 UTC

Re: MRT - How to remove all characters after a string

Post by *Gral »

What about:
Search: .jpg*
Replace .jpg
Without RegEx?
Alexisback
Junior Member
Junior Member
Posts: 80
Joined: 2016-10-26, 20:04 UTC

Re: MRT - How to remove all characters after a string

Post by *Alexisback »

Gral wrote: 2022-02-24, 19:23 UTC What about:
Search: .jpg*
Replace .jpg
Without RegEx?
Thanks, this works :D , why doesn't it work RegEx :|
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: MRT - How to remove all characters after a string

Post by *Stefan2 »

Alexisback wrote: 2022-02-24, 19:31 UTC , why doesn't it work RegEx :|

It doesn't work because you didn't read the help (F1-key inside of MRT)

We do not have Lookaround whit the regex engine in use.





 
Alexisback
Junior Member
Junior Member
Posts: 80
Joined: 2016-10-26, 20:04 UTC

Re: MRT - How to remove all characters after a string

Post by *Alexisback »

Stefan2 wrote: 2022-02-24, 19:38 UTC
Alexisback wrote: 2022-02-24, 19:31 UTC , why doesn't it work RegEx :|

It doesn't work because you didn't read the help (F1-key inside of MRT)

We do not have Lookaround whit the regex engine in use.
ok, I'll give a look at that section
thank you all
User avatar
solid
Power Member
Power Member
Posts: 749
Joined: 2004-08-09, 11:20 UTC

Re: MRT - How to remove all characters after a string

Post by *solid »

Alexisback wrote: 2022-02-24, 19:31 UTC Thanks, this works :D , why doesn't it work RegEx :|
What is your version of TC?

Stefan2 wrote: 2022-02-24, 19:38 UTC It doesn't work because you didn't read the help (F1-key inside of MRT)

We do not have Lookaround whit the regex engine in use.
It seems that TC Regex engine started supporting assertions (positive/negative look behind/ahead). Yes, it is in the help file, I was surprised too.

TC History doesn't mention anything about this, but there is a line about an update of the regex library in TC10_PB3.
User avatar
tuska
Power Member
Power Member
Posts: 4060
Joined: 2007-05-21, 12:17 UTC

Re: MRT - How to remove all characters after a string

Post by *tuska »

Alexisback wrote: 2022-02-24, 18:22 UTC Why doesn't this regular expression work? :?:
(?<=.jpg).*
It works...

Code: Select all

Trova:		  (?<=.jpg).*
Sostituisci con:  <Cancella>
1x		  [✓]
RegEx		  [✓] 
Sostituisci	  [ ]

Code: Select all

Veccio nome											Nuovo nome
-_0qxe-yGro.jpg@size=960x720&quality=96&sign=25ff49e3eaba39ed3ca04908c6f779f4&type=album	-_0qxe-yGro.jpg
Help - F1 wrote:1x  Only replace the first occurrence of the search string if it appears multiple times in the file name
Help - F1 wrote:Subst. Substitution: The entire file name will be replaced by the characters entered in the "Replace" field.
If this option isn't checked, only the found expression will be replaced.
You can work with subexpressions, see the sample in regular expressions.
HISTORY.TXT wrote:25.03.21 Release Total Commander 10.00 public beta 3
23.03.21 Added: Updated the internal regular expression library to latest version from https://github.com/andgineer/TRegExpr/ (32/64)
TC (TRegExpr) ==> does support "Lookaround-Assertions", e.g. "lookahead" and "lookbehind" up from TC 10.00 public beta 3 (25.3.21).
Help - F1 wrote:Important note: The used regex library has a limitation that look ahead must be at the end of the regular expression,
and look behind must be at the start. Otherwise an error will be shown.
Alexisback
Junior Member
Junior Member
Posts: 80
Joined: 2016-10-26, 20:04 UTC

Re: MRT - How to remove all characters after a string

Post by *Alexisback »

solid wrote: 2022-02-25, 13:08 UTC
Alexisback wrote: 2022-02-24, 19:31 UTC Thanks, this works :D , why doesn't it work RegEx :|
What is your version of TC?
9.12 x64
yes, I know I have to update, but the fact that this version is customized with menu and script

HISTORY.TXT wrote:
25.03.21 Release Total Commander 10.00 public beta 3
23.03.21 Added: Updated the internal regular expression library to latest version from https://github.com/andgineer/TRegExpr/ (32/64)
that's why it doesn't work
User avatar
solid
Power Member
Power Member
Posts: 749
Joined: 2004-08-09, 11:20 UTC

Re: MRT - How to remove all characters after a string

Post by *solid »

Alexisback wrote: 2022-02-26, 04:49 UTC 9.12 x64
yes, I know I have to update, but the fact that this version is customized with menu and script
I believe all the users here have heavily customized versions of TC. No harm is done while updating.
Just in case, make a backup at least of the settings prior to updating,
Post Reply