Lasso Soft Inc. > Home

[pk_removeextension]

Linkpk_removeextension
AuthorPier Kuipers
CategoryString
Version6.x
LicensePublic Domain
Posted05 Jul 2006
Updated05 Jul 2006
More by this author...

Description

This tag removes the last occurrence of a period followed by any number of characters from the end of a string. Used to isolate a filename from its extension.

Sample Usage

pk_removeextension('this is my filename.jpg')
   -> 'this is my filename'

pk_removeextension('this.is.my.filename.jpg')
   -> 'this.is.my.filename'

pk_removeextension('this is my filename')
   -> 'this is my filename'

Source Code

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.

	if: !(lasso_tagexists: 'pk_removeextension');

		define_tag:'removeextension', -namespace='pk_',
			-required='filename',
			-description='removes the last occurrence of a period followed by any number of characters from the end of a string';
	
			local('output')=string;
	
			if(local_defined('filename'));

				local:'tempArray' = #filename -> split:'.';
				if((#tempArray -> size) > 1);
					#tempArray -> remove;
				/if;
				#output = (#tempArray -> join:'.');
	
			/if;
	
			return(#output);
	
		/define_tag;
	
	/if;

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft