Module talk:String

Latest comment: 20 days ago by Enhancing999 in topic New function: str lenletters

Please add the following function

edit

{{Editprotected}} It's for matching end of lines. Usage:

{{#invoke:String|count|source_str|pattern_string}}

OR

{{#invoke:String|count|source= source_string |pattern= pattern_string}}

Returns "yes" if the source string ends with the pattern string. Both strings are trimmed before use.

  • "{{#invoke:String|endswith|xxxyyy|y}}" → "yes"
  • "{{#invoke:String|endswith|xxxyyy|z}}" → ""

- Premeditated (talk) 15:42, 8 August 2019 (UTC)Reply

  Done -- User: Perhelion 16:43, 19 August 2019 (UTC)Reply

Proposal

edit

This is not a simple edit request – somebody with better LUA knowlegde than me should insert the functions in a good way. {{Editprotected}} String is a very good usable module; nevertheless I missed the function to remove delimiters from a character string, like e.g. "..." or (...) or [...].
For the problem of #, *, ; or : the nolist tag is not a perfect solution, but LUA can solve it perfectly. I need that function for several high used templates.
With my very poor LUA knowledge I wrote sarang/sandbox and brought it finally to functionality.
I suppose that others might sometimes need such functions as well. In especial, the function I called "unlist" is very helpful, and easy to code in LUA but elaborate as a template.
How about integrating the additional functions of my code into String (with useful function names, and better coding)? Otherwise I shall generate an own string-expansion module from that sandbox coding. -- sarang사랑 12:36, 23 August 2019 (UTC)Reply

Please take care: two examples are now not working correctly:
{{#invoke:Sarang/string|unwrap|"Test text string°||°}} "Test text string°
{{#invoke:Sarang/string|unwrap|오사랑시|오|시}} 오사랑시
(with some LUA knowledge the code can be repaired)
Hey Sarang, I would also operate first a separate module. Is not the strip function from en:Module:StringFunc what you looking for!? You could import the whole module here. -- User: Perhelion 15:08, 10 September 2019 (UTC)Reply
Thank you, @Perhelion: for the # * ; : problem I created the Char, with invoke:Char|subst (or invoke:Char|substitute if someone likes that better) the well known problem of e.g. the colon in a category name can be avoided.
The strip function in the module StringFunc works a bit different to what I was needing, when I looked for something to remove the delimiters from a text string, like e.g. "..." or (...). -- sarang사랑 07:45, 11 September 2019 (UTC)Reply
Tagged for a year with edit protected, but unclear what needs to be done. Please prepare the change in a sandbox so it can be tested and deployed later here. Multichill (talk) 13:32, 7 August 2020 (UTC)Reply
  •   Comment a new functions should probably be added to a new module, since this is a clone of a module copied from another project and is occasionally synched with the original to take advantage of improvements made to the master copy. --Jarekt (talk) 16:46, 7 August 2020 (UTC)Reply
@Sarang: I am still not sure exactly what functionality is needed. If you still need it can you create some list of example inputs and outputs? --Jarekt (talk) 18:55, 15 October 2020 (UTC)Reply
Thank you Jarekt: with another solution I could use that function, and when nobody else needs it, I withdraw my request. -- sarang사랑 05:15, 16 October 2020 (UTC)Reply

New function: str lenletters

edit

Maybe it can already be done now? This would help for {{Text cat}}, see Template_talk:Text_cat#Default_letter_count. Currently it's using {{Str len}} or a manual input. Enhancing999 (talk) 07:57, 18 June 2024 (UTC)Reply

Return to "String" page.