Menu

#2812 Placeholder to find text with regex

KeePass
open
nobody
5
2024-05-13
2023-03-29
No

Today, there is the placeholder {T-REPLACE-RX:/Text/Search/Replace/}.
I would like a placeholder like {T-FIND-RX:/Text/Search/}.

The result is the return of the query.

This will make regex simpler than using replace in many situations.

Thanks,
Miguel Motta

Discussion

  • T. Bug Reporter

    T. Bug Reporter - 2023-03-29

    The KeePass help file includes this info about T-REPLACE-RX:

    Usage example. Let the user name field contain the e-mail address myname@example.com and the URL field {T-REPLACE-RX:!{USERNAME}!.*@(.*)!https://$1!}. When running the URL field, KeePass opens https://example.com.

    This shows that the regex evaluator used for this does accept constructs that use the data found by the /Search/ expression to build the /Replace/ expression. The upshot of this is that you can build your own T-FIND-RX function by specifying a null replacement: {T-REPLACE-RX:/Text/(Search)/$1/}.

     
  • Miguel Motta

    Miguel Motta - 2023-03-29

    Hi!

    Yes, I understand that the FIND can be used with REPLACE.

    Idea is replace:

    {T-REPLACE-RX:!{USERNAME}!.*@(.*)!https://$1!)}

    By:

    https://{T-FIND-RX:!{USERNAME}!(?<=@).*!}

     

    Last edit: Miguel Motta 2023-03-29
  • Paul

    Paul - 2024-05-09

    No point in adding a Find version because the result is the same in a placeholder.

    cheers, Paul

     
  • T. Bug Reporter

    T. Bug Reporter - 2024-05-13

    I guess this proposal boils down to "Is the convenience of having a separate {T-FIND-RX} command great enough to justify its existence?" Obviously, the OP thinks it does, but it probably depends more on how easy it would be to implement.

     

Log in to post a comment.