Author Topic: Additional Tagging & Reporting Tools  (Read 929739 times)

boroda

  • Sr. Member
  • ****
  • Posts: 4595
its possible, not very inconvenient: *(^.*)/\\@sc($1)

redwing

  • Guest
I'm not sure how to use vertical bar as "or" with multiple search and replace preset.

either
*cat|dog/rabbit
or
*cat\|dog/rabbit

doesn't work.

also try using it inside parenthesis

*(cat|dog)/red-$1
*(cat\|dog)/red-$1

doesn't work either.
Last Edit: March 17, 2018, 01:08:46 AM by redwing

boroda

  • Sr. Member
  • ****
  • Posts: 4595
| as 'or' has priority (its not 'or' for searching, its 'or' for both searching and replacement), then / as delimiter for search/replace. escapes are used only for designating appropriate symbols. i dont understand your examples, there must be even number of search/replace items. eg:

cat/dog|the/a     cat->dog  and  the->a

if you want to use 'or' just for searching, its just generic regex (a|b), but it will require escape because | is reserved by preset:

*(cat\|dog)/red-$1    must work, will check tomorrow.

p.s. it was a good experiment, but its not usable. even you don't fully understand how to use this preset. i think 99% users wont be able to use it even with someones help.

p.p.s i'll write dedicated 'multiple search and replace' command (frontend for this preset).

redwing

  • Guest
The problem is it's not clear whether \| means the vertical line character or "or" when it's used in regex.
I think this should work in this case.

*cat|dog/rabbit

because it starts with * then all following string before / should be read as regex pattern regardless of its use in this preset.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
anyway syntax is very complex and can be suited only for examples. try to replace using preset:

1. ^(.*?)\sand\sDog   -  > $1
2. (.*)[^ab^c]\s*or\s+Cat  - > \@tc($1)

i even these regexes read with very much efforts. i can imagine how all this will look in preset :\

redwing

  • Guest
A separate command would be nice with search/replace boxes and tickbox for case sensitive and regex for each line. That would eliminate the need for all meta-characters.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
yes, its what i'm thinking of. also i think it will be good to make regexes optional for every line (step).

boroda

  • Sr. Member
  • ****
  • Posts: 4595
I'm not sure how to use vertical bar as "or" with multiple search and replace preset.

either
*cat|dog/rabbit
or
*cat\|dog/rabbit

doesn't work.

also try using it inside parenthesis

*(cat|dog)/red-$1
*(cat\|dog)/red-$1

doesn't work either.

bugs, bugs, bugs...

from tests all is working fine now. its required for dedicated command because preset and command will share code base.

use: *(cat\|dog)/red-$1


http://www.mediafire.com/file/lwlwpj80h8m8ayz/mb_TagTools_2018-03-17.zip

redwing

  • Guest
That works. Thanks!
And I found \\| works for matching the character in regex.

BTW when you create the separate command, it would be great if each step has a tickbox to enable/disable it. Then users could save all of frequently used templates in the preset, and just tick some of them to apply.

redwing

  • Guest
I was testing case conversion command and found it doesn't work properly when the search pattern contains a vertical bar.

For a string "cat dog rabbit"

*(cat\|dog\|rabbit)/$1

returns the same so it's working fine.

Now if you try

*(cat\|dog\|rabbit)/\\@tc($1)

it returns

Rabbit Rabbit Rabbit

instead of

Cat Dog Rabbit

boroda

  • Sr. Member
  • ****
  • Posts: 4595
That works. Thanks!
And I found \\| works for matching the character in regex.

BTW when you create the separate command, it would be great if each step has a tickbox to enable/disable it. Then users could save all of frequently used templates in the preset, and just tick some of them to apply.
command wont touch exactly this preset, instead you will able to save custom copies of this preset. its only for auto applying purposes, no other sense to save presets.here is what i have at the moment (still buggy):



redwing

  • Guest
Can you add one more tickbox to each line(step) that will include/exclude the step when applying?
Then users could save some complex templates to those steps and tick only some of them to apply depending on the given string.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
no, all steps wont be saved upon window close, command will act like mb native search and replace, but it with multiple steps and possibility to save presets.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
I was testing case conversion command and found it doesn't work properly when the search pattern contains a vertical bar.

For a string "cat dog rabbit"

*(cat\|dog\|rabbit)/$1

returns the same so it's working fine.

Now if you try

*(cat\|dog\|rabbit)/\\@tc($1)

it returns

Rabbit Rabbit Rabbit

instead of

Cat Dog Rabbit
its because its equivalent to: \\@tc(cat) \\@tc(dog) \\@tc(rabbit)

and unfortunately the same asr function (eg \\tc()) is supported only once per expression. it would be *very* difficult to fix this. this issue is not the problem for other presets (considering support for 5 steps), but not for this preset.

redwing

  • Guest
OK. Thanks!

BTW if it's not possible to save templates to each step box, it could be saved as comments since it's an xml file, right?
Then the user could copy and paste if there's a comments box to save templates.