[pk_removeextension]

Description

Link: [pk_removeextension]
Author: Pier Kuipers
Category: String
Version: 6.x
License: Public Domain
Posted: Jul. 05, 2006
Updated: Jan. 01, 0001
More by this author...
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.

Parameters

none


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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net