Regular Expresion Search not working at end of string

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
isidro
Junior Member
Junior Member
Posts: 96
Joined: 2006-03-21, 04:39 UTC
Location: argentina

Regular Expresion Search not working at end of string

Post by *isidro »

Want to delete all DE-de*.* files/folder, except DE-def*.* or DE-dea*, ie: "DE-define", "DE-de", "DE-de dict", "DE-dea" should return: "DE-de", "DE-de dict"
My regular expresion search is: DE-de[^af] which works in textpad, even if "DE-De" is alone in a line, but doesn't work on TotalCommander:
"DE-de" is NOT matched. I do have lot of similar searches with same problem...
Is there a workaround to make that search?
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Regular Expresion Search not working at end of string

Post by *petermad »

Have you tried: DE-de($|[^af])
Last edited by petermad on 2023-03-04, 02:13 UTC, edited 1 time in total.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Regular Expresion Search not working at end of string

Post by *Dalai »

Can't tell why the negated class doesn't find/match the line end, but

Code: Select all

de-de($|[^af])
works for your example.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Regular Expresion Search not working at end of string

Post by *white »

isidro wrote: 2023-03-04, 00:54 UTC My regular expresion search is: DE-de[^af] which works in textpad, even if "DE-De" is alone in a line...
No, it doesn't. Try "DE-De" on the last line of a file.
isidro wrote: 2023-03-04, 00:54 UTC Is there a workaround to make that search?
You can use the expression given by the other users, or following your line of thinking, you can do a Negative Lookahead search:

Code: Select all

DE-de(?![af])
Dalai wrote: 2023-03-04, 01:46 UTC Can't tell why the negated class doesn't find/match the line end, but
[ ] denotes a Character class. So it matches a character, which can also be a newline character. There is no newline character in filenames.
In contrast, $ denotes a line or string boundary.
isidro
Junior Member
Junior Member
Posts: 96
Joined: 2006-03-21, 04:39 UTC
Location: argentina

Re: Regular Expresion Search not working at end of string

Post by *isidro »

white wrote: 2023-03-04, 10:14 UTC You can use the expression given by the other users, or following your line of thinking, you can do a Negative Lookahead search:
That works great, thanks for the explanation. RE is a whole new world.
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Regular Expresion Search not working at end of string

Post by *white »

Moderator message from: white » 2023-03-04, 15:05 UTC

Moved from Bugs forum to English forum.
isidro
Junior Member
Junior Member
Posts: 96
Joined: 2006-03-21, 04:39 UTC
Location: argentina

Re: Regular Expresion Search not working at end of string

Post by *isidro »

actually I'm trying to find all regional non english files, adding some exceptions of non regional files; my full expression gives error "lookaround brackets must be at the very begining/ending":

Code: Select all

ar_ae|ar_sa(?![b])|az_az|ba_ba|be_by|bg_bg|bn_bd|ca_ca|(ca|eu|gl|va)_es|cn_sc|cn_tc|cs_cz|cz_cz|da_dk|de_(ch|de)(?![af])|el_gr(?![o])|en_(ae|au|ca|gb|il|xc|xm)|es_as|et_ee|fa_ir|fi_fi|fil_ph|fr_(be|br|ca|fr|ma|mx|xm)|gd_gb|he_il|hi_in|hr_hr|hu_hu|hy_am|id_id|in_in(?![fli])|is_is(?![a])|it_it|ja_jp|jp_jp|ka_ge|kk_kz|ko_kr|lt_lt|lv_lv|mk_mk|mk_yu|mn_mn|mt_mt|(nb|nn|no)_no|nl_nl|pa_in|pl_pl(?![a])|pt_br|pt_pt|ro_ro|ru_ru|sh_yu|sk_sk|sl_si|slo_slo|sq_al|sr_(cs|cir|sp|yu)|sv_(fi|se|sv)|th_th(?![e])|tl_ph|tr_tr|ua_ua|ug_cn|uk_ua|vi_vn|zh_chs|zh_(cht|cn|hk|mo|sg|tw)
Something simpler also gives the error:

Code: Select all

ar_ae|ar_sa(?![b])|az_az
This succeeds:

Code: Select all

ar_ae|ar_sa(?![b])
In textpad all works with no errors, any idea of why it doesn't work here?
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Regular Expresion Search not working at end of string

Post by *Ovg »

https://regex.sorokin.engineer/en/latest/regular_expressions.html?highlight=lookbehind#assertions

"...... Brackets for lookahead must be at the very ending of expression, and brackets for lookbehind must be at the very beginning. So assertions between choices |, or inside groups, are not supported. ....."

Try to use Everything (www.voidtools.com) with TC
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
isidro
Junior Member
Junior Member
Posts: 96
Joined: 2006-03-21, 04:39 UTC
Location: argentina

Re: Regular Expresion Search not working at end of string

Post by *isidro »

Ovg wrote: 2023-03-18, 05:35 UTC Try to use Everything (www.voidtools.com) with TC
"Everything" program would be better if it could manage to use internal windows Search database instead of adding another service and database for same task. Anyways, I hate things running in background so "Everything" is not an option. I even have Search service disabled among hundreds of other things (check my optimwin-batch in sourceForge which I will update soon).

Working solution is using first suggested solution ($|[^xyz]):

Code: Select all

ar_ae|ar_sa|az_az|ba_ba|be_by|bg_bg|bn_bd|ca_ca|(ca|eu|gl|va)_es|cn_sc|cn_tc|cs_cz|cz_cz|da_dk|de_(ch|de)($|[^af])|el_gr($|[^o])|en_(ae|au|ca|gb|il|xc|xm)|es_as|et_ee|fa_ir|fi_fi|fil_ph|fr_(be|br|ca|fr|ma|mx|xm)|gd_gb|he_il|hi_in|hr_hr|hu_hu|hy_am|id_id|in_in($|[^fli])|is_is($|[^a])|it_it|ja_jp|jp_jp|ka_ge|kk_kz|ko_kr|lt_lt|lv_lv|mk_mk|mk_yu|mn_mn|mt_mt|(nb|nn|no)_no|nl_nl|pa_in|pl_pl($|[^a])|pt_br|pt_pt|ro_ro|ru_ru|sh_yu|sk_sk|sl_si|slo_slo|sq_al|sr_(cs|cir|sp|yu)|sv_(fi|se|sv)|th_th($|[^e])|tl_ph|tr_tr|ua_ua|ug_cn|uk_ua|vi_vn|zh_chs|zh_(cht|cn|hk|mo|sg|tw)
And same with upper - instead of underscore _ for other cases:

Code: Select all

ar-ae|ar-sa|az-az|ba-ba|be-by|bg-bg|bn-bd|ca-ca|(ca|eu|gl|va)-es|cn-sc|cn-tc|cs-cz|cz-cz|da-dk|de-(ch|de)($|[^af])|el-gr($|[^o])|en-(ae|au|ca|gb|il|xc|xm)|es-as|et-ee|fa-ir|fi-fi|fil-ph|fr-(be|br|ca|fr|ma|mx|xm)|gd-gb|he-il|hi-in|hr-hr|hu-hu|hy-am|id-id|in-in($|[^fli])|is-is($|[^a])|it-it|ja-jp|jp-jp|ka-ge|kk-kz|ko-kr|lt-lt|lv-lv|mk-mk|mk-yu|mn-mn|mt-mt|(nb|nn|no)-no|nl-nl|pa-in|pl-pl($|[^a])|pt-br|pt-pt|ro-ro|ru-ru|sh-yu|sk-sk|sl-si|slo-slo|sq-al|sr-(cs|cir|sp|yu)|sv-(fi|se|sv)|th-th($|[^e])|tl-ph|tr-tr|ua-ua|ug-cn|uk-ua|vi-vn|zh-chs|zh-(cht|cn|hk|mo|sg|tw)
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Regular Expresion Search not working at end of string

Post by *Ovg »

isidro wrote: 2023-03-19, 01:27 UTC "Everything" program would be better if it could manage to use internal windows Search database ......
Everything 1.5 working with Windows Search just fine ....
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
isidro
Junior Member
Junior Member
Posts: 96
Joined: 2006-03-21, 04:39 UTC
Location: argentina

Re: Regular Expresion Search not working at end of string

Post by *isidro »

Ovg wrote: 2023-03-19, 08:04 UTC
isidro wrote: 2023-03-19, 01:27 UTC "Everything" program would be better if it could manage to use internal windows Search database ......
Everything 1.5 working with Windows Search just fine ....
I didn't said it doesn't, what I meant is I don't like having two programs running to do the same task. Everything would be better if instead of having it's own Database and Service, would use the already running windows Search Service and database and save resources. In some limited machines I even disable Windows Search Service to gain some speed.
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Regular Expresion Search not working at end of string

Post by *tuska »

isidro wrote: 2023-03-29, 15:00 UTC
Ovg wrote: 2023-03-19, 08:04 UTC
isidro wrote: 2023-03-19, 01:27 UTC "Everything" program would be better if it could manage to use internal windows Search database ......
Everything 1.5 working with Windows Search just fine ....
... Everything would be better if instead of having it's own Database and Service,
would use the already running windows Search Service and database and save resources.
In my opinion, the Everything Service does not need to be mentioned in this context,
because it only needs between 1.2 and 1.4 MB RAM.

You can also keep the database (Everything.db) small if you do not use the options "Properties" and "Content"
in Everything 1.5a and instead define these settings in Windows Search.

Access to the Windows search in Everything is possible with the parameter: si:
and in Total Commander with the parameter: ev:si:.

See also:
- Content & Properties in Everything 1.5a - My Settings - Example
- 14. Windows Search in Total Commander and 'Everything'
isidro
Junior Member
Junior Member
Posts: 96
Joined: 2006-03-21, 04:39 UTC
Location: argentina

Re: Regular Expresion Search not working at end of string

Post by *isidro »

tuska wrote: 2023-03-29, 18:38 UTC In my opinion, the Everything Service does not need to be mentioned in this context,
because it only needs between 1.2 and 1.4 MB RAM.
Problem is not only RAM (and I seriously doubt so little usage with >300k files in a small win10 (only one monthly update will leave >100k useless files&folders in Windows\Servicing\LCU folder). But also the overhead on file operations due to multiple index updates. On old mechanic HDs this will result in slower operation. My approach is to avoid unnecessary background programs, ideally none. XP was a lot better in that aspect, since win7 MS started bloated taskscheduler with >100 useless tasks, etc.
Post Reply