Return to Snippet

Revision: 28024
at July 9, 2010 00:38 by riddla


Updated Code
function slugify(s)
{
	//s = 'Was wäre daß® für ein + unnützer Tést?';
	
	var slug = s;
	
	slug = slug.toLowerCase();
	slug = slug.replace(/\s+/g,'-');
	
	tr = { 
		'\u00e4':'ae',
		'\u00fc':'ue',
		'\u00f6':'oe',
		'\u00df':'ss',
		'\u00df':'ss',
		'\u00e9':'e',
		'/':'-'
	}
	
	for ( var key in tr )
	{
		slug = slug.replace(new RegExp(key, 'g'), tr[key]);
	}
	
	slug = slug.replace(/[^a-zA-Z0-9\-]/g,'');
	slug = slug.replace(/-+/g, '-');
	
	//alert(slug);
	// return(s);
	
	return slug;
}

Revision: 28023
at July 9, 2010 00:38 by riddla


Updated Code
function slugify(s)
{
	//s = 'Was wäre da�® für ein + unnützer Tést?';
	
	var slug = s;
	
	slug = slug.toLowerCase();
	slug = slug.replace(/\s+/g,'-');
	
	tr = { 
		'\u00e4':'ae',
		'\u00fc':'ue',
		'\u00f6':'oe',
		'\u00df':'ss',
		'\u00df':'ss',
		'\u00e9':'e',
		'/':'-'
	}
	
	for ( var key in tr )
	{
		slug = slug.replace(new RegExp(key, 'g'), tr[key]);
	}
	
	slug = slug.replace(/[^a-zA-Z0-9\-]/g,'');
	slug = slug.replace(/-+/g, '-');
	
	//alert(slug);
	// return(s);
	
	return slug;
}

Revision: 28022
at July 5, 2010 18:36 by riddla


Updated Code
function slugify(s)
{
	//s = 'Was wäre daß® für ein + unnützer Tést?';
	
	var slug = s;
	
	slug = slug.toLowerCase();
	slug = slug.replace(/\s+/g,'-');
	
	tr = { 
		'\u00e4':'ae',
		'\u00fc':'ue',
		'\u00f6':'oe',
		'\u00df':'ss',
		'\u00df':'ss',
		'\u00e9':'e',
		'/':'-'
	}
	
	for ( var key in tr )
	{
		slug = slug.replace(new RegExp(key, 'g'), tr[key]);
	}
	
	slug = slug.replace(/[^a-zA-Z0-9\-]/g,'');
	slug = slug.replace(/-+/g, '-');
	
	//alert(slug);
	// return(s);
	
	return slug;
}

Revision: 28021
at July 5, 2010 18:36 by riddla


Updated Code
function slugify(s)
{
	//s = 'Was wäre da�® für ein + unnützer Tést?';
	
	var slug = s;
	
	slug = slug.toLowerCase();
	slug = slug.replace(/\s+/g,'-');
	
	tr = { 
		'\u00e4':'ae',
		'\u00fc':'ue',
		'\u00f6':'oe',
		'\u00df':'ss',
		'\u00df':'ss',
		'\u00e9':'e',
		'/':'-'
	}
	
	for ( var key in tr )
	{
		slug = slug.replace(new RegExp(key, 'g'), tr[key]);
	}
	
	slug = slug.replace(/[^a-zA-Z0-9\-]/g,'');
	slug = slug.replace(/-+/g, '-');
	
	//alert(slug);
	// return(s);
	
	return slug;
}

Revision: 28020
at July 1, 2010 19:26 by riddla


Updated Code
function slugify(s)
{
	//s = 'Was wäre daß® für ein + unnützer Tést?';
	
	var slug = s;
	
	slug = slug.toLowerCase();
	slug = slug.replace(/\s+/g,'-');
	
	tr = { 
		'\u00e4':'ae',
		'\u00fc':'ue',
		'\u00f6':'oe',
		'\u00df':'ss',
		'\u00df':'ss',
		'\u00e9':'e',
		'/':'-'
	}
	
	for ( var key in tr )
	{
		slug = slug.replace(new RegExp(key, 'g'), tr[key]);
	}
	
	slug = slug.replace(/[^a-zA-Z0-9\-]/g,'');
	slug = slug.replace(/-+/g, '-');
	
	//alert(slug);
	// return(s);
	
	return slug;
}

Revision: 28019
at July 1, 2010 19:25 by riddla


Updated Code
function slugify(s)
{
	//s = 'Was wäre daß® für ein + unnützer Tést?';
	
	tr = { 
		'\u00e4':'ae',
		'\u00fc':'ue',
		'\u00f6':'oe',
		'\u00df':'ss',
		'\u00df':'ss',
		'\u00e9':'e',
		'/':'-'
	}
	
	var slug = s.toLowerCase();
	slug = slug.replace(/\s+/g,'-');
	
	for ( var key in tr )
	{
		slug = slug.replace(new RegExp(key, 'g'), tr[key]);
	}
	
	slug = slug.replace(/[^a-zA-Z0-9\-]/g,'');
	slug = slug.replace(/-+/g, '-');
	
	//alert(slug);
	// return(s);
	
	return slug;
}

Revision: 28018
at June 29, 2010 22:41 by riddla


Updated Code
function slugify(s)
{
	// Was wäre daß® für ein + unnützer Test?
	
	tr = {"\u00e4":"ae", "\u00fc":"ue", "\u00f6":"oe", "\u00df":"ss" }
	
	var slug =
				s
				.toLowerCase()
				.replace(/\s+/g,'-')
				.replace(/[\u00e4|\u00fc|\u00f6|\u00df]/g, function($0) { return tr[$0] })
				.replace(/[^a-zA-Z0-9\-]/g,'')
				.replace(/-+/g, '-')
	;
	
	return slug;
}

Revision: 28017
at June 29, 2010 22:40 by riddla


Initial Code
function slugify(s)
{
	// Was wäre daß® für ein + unnützer Test?
	
	var slug =
				s
				.toLowerCase()
				.replace(/\s+/g,'-')
				.replace(/[\u00e4|\u00fc|\u00f6|\u00df]/g, function($0) { return tr[$0] })
				.replace(/[^a-zA-Z0-9\-]/g,'')
				.replace(/-+/g, '-')
	;
	
	return slug;
}

Initial URL

                                

Initial Description

                                

Initial Title
Slugify - JavaScript version

Initial Tags
javascript

Initial Language
JavaScript