View Single Post
Old 02-24-2023, 05:31 AM   #5
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 167
Karma: 1497966
Join Date: Jul 2021
Device: N/A
Quote:
Originally Posted by F4in7_ View Post
I'm bad at describing how to make this work, but right now I have more than a dozen saved searches trying to align ellipses to each other including quotation marks.

Here's a list of them, and I'm figuring out a way to simplify them.
If I understand correctly, you want to transform 3 dots (with or without spaces) in ellipsis, always remove a space before, and always remove a space after except if it's a letter.

You can do this with a regex-function :
Code:
— search : 
\s?(?:(?:\. ?\. ?\. ?)|…) ?(.)?

— replace (in mode regex-function):

def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    end = match[1] or ''   # be sure is not None
    space = ' ' if end.isalpha() else ''
    return '…' + space + end
I don't understand lines 2 and 5
> '…' to '… '
It seems that you want to put a space where everywhere else (except letter) you want to remove it ? I didn't consider this case because I didn't understand the purpose.

> '*…' to '…'
I don't understand this *. It is a jocker ? I didn't consider it either, but if you want to match a star, the search should be :
Code:
\s?\*?(?:(?:\. ?\. ?\. ?)|…) ?(.)?
___________
Edit 1: made optional the last char.
The cavit is that it will transform all ellipsis to themselves, but it shouldn't be a handicap in terms of time. If you don't want this, it can be avoid using 2 different regex-functions.

Edit 2: added how to remove a star

Last edited by lomkiri; 02-24-2023 at 06:37 AM.
lomkiri is offline   Reply With Quote