Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Oa = Oaxy
- and au = auxy
- Gardenhire = Gardxy
- Parker = Parkxy
- Arney = Arnxy
- There are 4 rules.
- 1. The name cuts off at the second vowel and is replaced by 'xy.'
- 2. connected vowels count as a single and should stay together.
- 3. EXCEPTION: when the last letter is 'x' another 'x' is not added.
- 4. Names with only two connected vowels should have "xy" added to the end
- function doit(userName) {
- var temp = userName.toLowerCase();
- var vowels = "aeiouy"
- var count = 0;
- if(userName) {
- for(var i=0; i<temp.length; i++) {
- if( vowels.indexOf(temp.charAt(i)) > -1 ) {
- count++;
- if(count==1) {
- while( vowels.indexOf(temp.charAt(++i)) != -1 );
- i--;
- } else
- break;
- }
- }
- userName = userName.substr(0, i);
- if( userName.charAt(userName.length-1) == 's' )
- userName += "y";
- else
- userName += "sy";
- } else
- userName = 'Take a lap, Dummy';
- return userName.toUpperCase();
- }
- var word = "anumap";
- var transformed = word.replace(/(w+[aeiou]+).*/i, " $1xy");
- function doit(userName) {
- var str = userName || "";
- var vowels = ["a","e","i","o","u"];
- var suffix = "xy";
- var str_arr = str.split("");
- var str_arr_rev = str_arr.reverse();
- $.each(str_arr_rev, function (i, item) {
- if ($.inArray(item.toLowerCase(), vowels) > -1) {
- last_vowel_index = i;
- return false;
- }
- });
- if (last_vowel_index == -1) {
- $.each(str_arr_rev, function (i, item) {
- if (item.toLowerCase() == "y") {
- last_vowel_index = i;
- return false;
- }
- });
- }
- if (last_vowel_index > -1)
- str_arr_rev[last_vowel_index] = str_arr_rev[last_vowel_index] + suffix;
- return str_arr_rev.reverse().join("");
- }
- Oa = Oaxy and au = auxy -Anup
- <input type="text" value="" /><br />
- <div id="name"></div>
- $(function () {
- $("input").on("change", function(e) {
- $("#name")
- .html(function (index, o) {
- var v = /[aeiou]+.$/gi;
- var o = $(e.target).val();
- var n = v.test(o);
- return (n ? String(o.replace(/[^aeiou]$/gi, "") + "xy").toUpperCase() : o)
- });
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement