tasks/checkwpversion.js
function( version ){
		
		//lowercase
		version = version.toLowerCase();

		//Remove spaces;
		version = version.replace( ' ', '' );
		
		//Make delimiters all the same
		version = version.replace( '-', '.' );
		version = version.replace( '_', '.' );
		version = version.replace( '+', '.' );
		
		var length = version.length;
		var newVersion = false;
		
		newVersion = version[0];
		
		for( var i=1; i < length; i++ ){
			
			var a = version[i-1];
			var b = version[i];
			
			if( '.' === a || '.' === b ){
				newVersion += b;
				continue;
			}
			
			var sameType = ( isNaN( a ) === isNaN( b ) );
			
			
			if( sameType ){
				newVersion += b;
			}else{
				newVersion += "."+b;
			}
		
		}
	
		//Split at delimiter
		var versionArray = newVersion.split( '.' );
		
		//Filter empty parts
		versionArray = versionArray.filter( function(e){ return ( e !== "" ); } );
		
		//Convert special text into character form.
		versionArray = versionArray.map( function( e ){
			
			switch( e ){
				case 'alpha':
					return 'a';
				case 'beta':
					return 'b';
				case 'pl':
					return 'p';
				default:
					return e;
			}
		} );
		
		
		return versionArray.join('.');
	}
function( version ){
		
		//lowercase
		version = version.toLowerCase();

		//Remove spaces;
		version = version.replace( ' ', '' );
		
		//Make delimiters all the same
		version = version.replace( '-', '.' );
		version = version.replace( '_', '.' );
		version = version.replace( '+', '.' );
		
		var length = version.length;
		var newVersion = false;
		
		newVersion = version[0];
		
		for( var i=1; i < length; i++ ){
			
			var a = version[i-1];
			var b = version[i];
			
			if( '.' === a || '.' === b ){
				newVersion += b;
				continue;
			}
			
			var sameType = ( isNaN( a ) === isNaN( b ) );
			
			
			if( sameType ){
				newVersion += b;
			}else{
				newVersion += "."+b;
			}
		
		}
	
		//Split at delimiter
		var versionArray = newVersion.split( '.' );
		
		//Filter empty parts
		versionArray = versionArray.filter( function(e){ return ( e !== "" ); } );
		
		//Convert special text into character form.
		versionArray = versionArray.map( function( e ){
			
			switch( e ){
				case 'alpha':
					return 'a';
				case 'beta':
					return 'b';
				case 'pl':
					return 'p';
				default:
					return e;
			}
		} );
		
		
		return versionArray.join('.');
	}
function ( version ) { //lowercase version = version . toLowerCase ( ) ; //Remove spaces; version = version . replace ( ' ' , '' ) ; //Make delimiters all the same version = version . replace ( '-' , '.' ) ; version = version . replace ( '_' , '.' ) ; version = version . replace ( '+' , '.' ) ; var length = version . length ; var newVersion = false ; newVersion = version [ 0 ] ; for ( var i = 1 ; i < length ; i ++ ) { var a = version [ i - 1 ] ; var b = version [ i ] ; if ( '.' === a || '.' === b ) { newVersion += b ; continue ; } var sameType = ( isNaN ( a ) === isNaN ( b ) ) ; if ( sameType ) { newVersion += b ; } else { newVersion += "." + b ; } } //Split at delimiter var versionArray = newVersion . split ( '.' ) ; //Filter empty parts versionArray = versionArray . filter ( function ( e ) { return ( e !== "" ) ; } ) ; //Convert special text into character form. versionArray = versionArray . map ( function ( e ) { switch ( e ) { case 'alpha' : return 'a' ; case 'beta' : return 'b' ; case 'pl' : return 'p' ; default : return e ; } } ) ; return versionArray . join ( '.' ) ; }
Sanitize a version string

It does the following:

* Casts the string to lower case
* Empty spaces are removed
* Converts accepted delimiters ('.', '_', '-', '+') to '.'
* Adds a . between strings and non-strings: e.g. "1.4b1" becomes "1.4.b.1"
* Empty components are removed, e.g. "1.4..1" because "1.4.1"
* "alpha", "beta", "pl" are converted to their 1-character equivalents: "a", "b", "p"

@param version
@returns
Sanitize a version string