PS one more tweak to add: the

.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");

part does what

.escapeRegExp();

TW String utitity is supposed to do, and for better readability, I suggest 
to write those lines as following:

flag = flag.escapeRegExp();

One, however, should be aware, that this method is slower and is not 
totally "accurate" [1], but again, in this case it is ok.

[1] https://groups.google.com/forum/#!topic/tiddlywikidev/bZOI6X-AOvU

вторник, 20 мая 2014 г., 16:52:07 UTC+4 пользователь Yakov написал:
>
> Ok, here's what I think: now we have this RegExp:
> regexp = new RegExp(flag+"([^\\|\\n\\]]*)$|"+flag+"([^\\x00-\\xff]*)$", 
> "gi");
> and this use of match:
> return match[2] || match[1];
>
> As this is two alternative matches and my [^\\|\\n\\]] version is general 
> enough, looks like the second part may be omitted like this:
> regexp = new RegExp(flag+"([^\\|\\n\\]]*)$", "gi");
> and
> return match[1];
>
> I'll let you know if this causes any side-effects in tests, but it 
> shouldn't.
>
> Best regards,
> Yakov.
>
> вторник, 20 мая 2014 г., 15:55:52 UTC+4 пользователь Yakov написал:
>>
>> Hello Albert,
>>
>> I see, take your time and good luck :) Health to the boy!
>>
>> понедельник, 19 мая 2014 г., 15:14:12 UTC+4 пользователь Albert Riedinger 
>> написал:
>>>
>>> Hello Yakov,
>>>
>>> I'm very sorry for my delayed answer, but I'm currently very busy 
>>> ("waiting" for birth of my son in the next few days :)
>>> Thank you for all your tips and tweaks, but currently, I don't have the 
>>> time to work on a new release (but worked on a rewrite of my plugin about 2 
>>> weeks ago > v0.3 [not published yet]) or answer all your questions in a 
>>> detailled way. But I promise to get back in a few weeks ... I hope so :)
>>>
>>> Right, I hope you'll incorporate my tweaks in the future versions, so I 
>> wouldn't need to change the plugin each time ;)
>>  
>>
>>> ... |"+flag+"([^\\x00-\\xff]*)$ ...
>>>
>>> is a part of the original[1] regexp (see also [2]). I guess it is not 
>>> required because removing it doesn't make any difference. But I'm not 
>>> really sure. Hope that helps a bit.
>>>
>>> Ok, I'll take a look at this.
>>  
>>
>>> Best regards,
>>> Albert
>>>
>>> [1] 
>>> https://github.com/ichord/At.js/blob/master/dist/js/jquery.atwho.js#L657
>>> [2] http://regex101.com/r/lN2wG9
>>>
>>>
>>> 2014-05-16 23:21 GMT+02:00 Yakov <[email protected]>:
>>>
>>>> Hello Albert,
>>>>
>>>> I've stubled upon an issue -- when AutoSuggestPlugin is included 
>>>> (eval'ed without importing) via SharedTiddlersPlugin [1], the styles are 
>>>> not applied -- and made a quick fix for it: added the
>>>> refreshStyles("StyleSheetAutoSuggest");
>>>> line before the
>>>> store.addNotification("StyleSheetAutoSuggest", refreshStyles);
>>>> line, which seems to be worth including in the main plugin.
>>>>
>>>> Also, in my tweaked version, I've substituted the "chars" with the 
>>>> [^\\|\\n\\]] thing, but didn't get what ([^\\x00-\\xff]*) stands for, 
>>>> so could you point what's the purpose of this piece (so that I can turn it 
>>>> into some more readable RegExp?
>>>>
>>>> For the reference, I attach my tweaked snapshot of the plugin.
>>>>
>>>> Best regards,
>>>> Yakov.
>>>>
>>>> [1] http://yakovl.bplaced.net/TW/STP/STP.html
>>>>
>>>> среда, 16 апреля 2014 г., 0:47:59 UTC+4 пользователь Albert Riedinger 
>>>> написал:
>>>>
>>>>> Today I worked out a temporary solution for pretty links, so it is 
>>>>> possible now to type "[[SOME_LABEL|" which gives you tiddler title 
>>>>> suggestions.
>>>>> It was a tough nut to crack for a regex newbie like me, but it works 
>>>>> :)
>>>>>
>>>>> Try it out and have fun[1]!
>>>>> Albert
>>>>>
>>>>> [1] http://autosuggest.tiddlyspace.com/#AutoSuggestPlugin
>>>>>
>>>>  -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "TiddlyWiki" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at http://groups.google.com/group/tiddlywiki.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to