Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
$( 'h2.title' ).first().append( '<button id="c_encode">encode</button><button id="c_decode">decode</button>' );
var TARGET_CHAR = [ 'у' , 'е' , 'ё' , 'ы' , 'а' , 'о' , 'э' , 'я' , 'и' , 'ю' ];
$( '#c_encode' ).click(function(){
$( '.message.html_format' ).each(function(){
var src_text = $( this ).text();
var res_text = [];
for( var i = 0, l = src_text.length; i < l; i++ ){
if ( window.TARGET_CHAR.indexOf( src_text[i] ) !== -1 ){
res_text.push( src_text[i] + 'с' + src_text[i] );
} else {
res_text.push( src_text[i] );
}
}
$( this ).text( res_text.join( '' ) );
});
});
$( '#c_decode' ).click(function(){
$( '.message.html_format' ).each(function(){
var src_text = $( this ).text();
var res_text = [];
for( var i = 0, l = src_text.length; i < l; i++ ){
if ( window.TARGET_CHAR.indexOf( src_text[i] ) !== -1 ){
res_text.push( src_text[i] );
i = i + 2;
} else {
res_text.push( src_text[i] );
}
}
$( this ).text( res_text.join( '' ) );
});
});
re.sub(u"([аеёиоуыэюя])[сС]\\1", "\\1", s.decode('utf8'))
Мой ответ конкурсу Павла Дурова (запоздалая пятница)