Template talk:Strfind short

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

This is the discussion/talk-page for: Template:Strfind_short.

Created[edit]

The Template:Strfind_short was created by long-term user Wikid77 on 28 December 2010, to find strings using a shorter algorithm, to handle shorter strings. However, on 29 January 2011, it was updated to check the length parameter lenstr=n for search 5x faster, stopping at the length of specific strings, and that also allowed for searching longer strings, since the length would normally be shorter for shorter strings. -Wikid77 23:33, 4 February 2011 (UTC)[reply]

Ready for use?[edit]

Is this functioning yet? If so, I'll start updating the automatic taxobox code accordingly. Bob the Wikipedian (talkcontribs) 00:50, 3 January 2011 (UTC)[reply]

I'm assuming that this is ready now, since it's being proposed as an addition to the {{italictitle}}. Bob the WikipediaN (talkcontribs) 22:30, 4 February 2011 (UTC)[reply]
  • Yes, it is ready for use: it was tested on various lengths of strings and seems to work fine, but I am optimizing it again to check string lengths in increments of 10, 15, 20, 25 (etc.) to be even faster, using the 80/20 Rule to focus on the most-likely titles. Sorry, it took so long to optimize, but I had imagined most actual string lengths were less than 15 (NOT!), until I saw Template:Italic_title (used in 353,000 pages), and checked 10,000 titles to reveal many are 16-25 long, with few less than 5 characters long, but also having a few over 90 long. Don't be afraid to search titles of length "99" because they are extremely rare (1-in-10,000?) and will not "slow down" Wikipedia but allow searching a vast range of exotic album titles, etc. The prior search limit of length 50 was an unfortunate oversight, but if we all focus on various aspects of processing titles, we will soon have this optimized and flexible enough to work well in most articles. -Wikid77 23:33, 4 February 2011 (UTC)[reply]
So my question is this-- when implementing the new, faster search, I want to replace all instances of "str find" with "strfind short", correct? Or should this be used in some places, and a different one elsewhere? I'm prepared to begin updating the taxobox templates, and I want to make sure I get this right the first time so I don't have five or six bug reports within minutes of the first change I make. Bob the WikipediaN (talkcontribs) 00:23, 5 February 2011 (UTC)[reply]
To replace {str_find}, with {strfind_short}, also set the length of the base string (being searched) as lenstr:
{{strfind_short|{{{title}}}|{{{huntstr}}}|1 |lenstr={{strlen_quick|{{{title}}}}} }}
{{strfind_short|Ancyra (genus)|(|1 |lenstr={{strlen_quick|{{{title|Ancyra (genus)}}}}} }} → 8
Because the parameters differ from {str_find}, this is not a simple search-and-replace: care must be taken to check some various results, when {strfind_short} is used instead. There is a danger of misusing the parameters. In general: if you don't have time for bug reports, you don't have time to risk changes. It is not worth the risk, unless you have time to spare. I've learned that the hard way: a major change also requires time for major testing of results (and handling complaints). I wish it were simpler, but the likelihood is problems will occur, so you might want to change one thing at a time and check results, more slowly. -Wikid77
True that. Thanks for the advice. Bob the WikipediaN (talkcontribs) 02:54, 5 February 2011 (UTC)[reply]

Fix for hyphen[edit]

The Template:Strfind_short should be updated, from the /sandbox, to no longer ghost-match a hyphen and instead avoid matching internal prefix characters. After the update, the following should match:

  • Expected: {{strfind short|abcdef|-|1}} → 0
  • Currently: {{strfind short|abcdef|-|1}} → 0
  • Expected: {{strfind short|abc-def|-|1}} → 4
  • Currently: {{strfind short|abc-def|-|1}} → 4
  • Expected: {{strfind short|abcdef|dc|2}} → 0
  • Currently: {{strfind short|abcdef|dc|2}} → 0
  • Expected: {{strfind short|abcdedcf|dc|2}} → 6
  • Currently: {{strfind short|abcdedcf|dc|2}} → 6
  • Expected: {{strfind short|10400|-|1}} → 0
  • Currently: {{strfind short|10400|-|1}} → 0
  • Expected: {{strfind short|10400500600700800|-|1}} → 0
  • Currently: {{strfind short|10400500600700800|-|1}} → 0
  • Expected: {{strfind short|10400500600700-800|-|1}} → 15
  • Currently: {{strfind short|10400500600700-800|-|1}} → 15

Because {strfind_short} has had the bug to ghost-match a hyphen since December 2010, many users probably already know to avoid using hyphens in searches. However, after the update, then {strfind_short} could be used to search for hyphens, as well as the dashes already supported. -Wikid77 (talk) 20:57, 25 November 2012 (UTC)[reply]

Done. Very nice work indeed. — Mr. Stradivarius (have a chat) 10:46, 26 November 2012 (UTC)[reply]

Protected edit request on 31 August 2014[edit]

Can the two category tags ("[[Category:Wikipedia formatting and function templates]]" and "[[Category:Templates with minimal expansion depth]]") be removed from the main template page? Both tags are already included on (i.e., provided by) the "/doc" subpage. Jdaloner (talk) 22:15, 31 August 2014 (UTC)[reply]

DoneMr. Stradivarius ♪ talk ♪ 23:38, 31 August 2014 (UTC)[reply]

How is this different from {{str find}}...[edit]

... since both now use the same string module (other than having different error codes for not found). Guarapiranga  04:24, 29 May 2022 (UTC)[reply]