Link | lp_string_split |
Author | Bil Corry |
Category | String |
Version | 8.x |
License | Public Domain |
Posted | 05 Dec 2005 |
Updated | 05 Dec 2005 |
More by this author... |
Similar to ->split except -limit=n limits split to just n elements.
lp_string_split:'hello?1?2?3?','?',3; = [lp_string_split:'hello?1?2?3?','?',3] lp_string_split:'hello?1?2?3?','?'; = [lp_string_split:'hello?1?2?3?','?'] lp_string_split:'12345','',2; = [lp_string_split:'12345','',2] lp_string_split:'12345',''; = [lp_string_split:'12345','']
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
[ define_tag: 'lp_string_split', -description='Similar to ->split except -limit=n limits split to just n elements.', -priority='replace', -required='string', -copy, -required='delimiter', -copy, -optional='limit', -copy; #string = string:#string; #delimiter = string:#delimiter; local:'split' = #string->(split:#delimiter); if: !(local_defined:'limit'); return: #split; else; #limit = integer: #limit; local:'split_size' = #split->size; if: #limit < 2; return: (array: #string); else: #limit >= #split_size; return: #split; else; // split is more than the limit allows local:'newsplit' = array; loop: #split_size; if: loop_count < #limit; #newsplit->(insert: (#split->(get:1))); #split->(remove:1); else; #newsplit->(insert: (#split->(join:#delimiter))); return: #newsplit; /if; /loop; /if; /if; /define_tag; ]
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft