Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Content count

  • Joined

  • Last visited


About Gustavo6046

  • Rank
    Senior Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Single Status Update

See all updates by Gustavo6046

  1. This is it, I wrote the best Node.JS module ever!


    function caseRep(letter, low, upp) { return letter.toLowerCase() == letter ? low : upp; }
    function furrify(word) {
        return word
            .replace(/(w)(h)/gi, (match, w, h) => caseRep(w, 'u', 'U') + caseRep(h, 'w', 'W'))
            .replace(/(g)([aeiou])/gi, (match, g, vowel) => caseRep(g, 'g', 'G') + caseRep(vowel, 'y', 'Y') + vowel)
            .replace(/(o)(u)/gi, (match, o, u) => caseRep(o, 'e', 'E') + caseRep(u, 'e', 'E'))
            .replace(/(l)(l)/gi, (match, t, h) => caseRep(t, 'w', 'W') + caseRep(h, 'w', 'W'))
            .replace(/(t)(h)/gi, (match, t, h) => caseRep(t, 'd', 'D') + caseRep(h, 'h', 'H'))
            .replace(/ph/g, 'f')
            .replace(/ph/gi, 'F')
            .replace(/(p)(p)/gi, (match, p1, p2) => caseRep(p1, 'p', 'P'))
            .replace(/([lL])([aeiouAEIOU])/gi, (match, l, vowel) => caseRep(l, 'w', 'W') + vowel)
            .replace(/y(?=[\.\,\;\:\?\!])|y^/gi, (y) => caseRep(y, 'ya', 'YA'))
            .replace(/r(?=[\.\,\;\:\?\!])|r^/gi, (r) => caseRep(r, 'y', 'Y'))
            .replace(/(r)/gi, (match, r) => caseRep(r, 'y', 'Y'))
            .replace(/y(?=!a)/gi, (y) => caseRep(y, 'ii', 'II'))
            .replace(/(i)(n)/gi, (match, i, n) => caseRep(i, 'iy', 'IY') + n);
    module.exports = furrify


    Use case:

    $ node
    > var furrify = require('./furrify.js')
    > furrify('Why did I write this?')
    'Uwy did I wyite dhis?'
    > furrify('Were I sober? Were I serious? Were I even myself?')
    'Weye I sobey? Weye I seyiees? Weye I even myself?'
    > furrify("Gah, I can't even think!")
    'Gyah, I can\'t even dhiynk!'
    > furrify('And I thought I had sanity enough to be the President of the Brazilian Republic.')
    'And I dheeght I had sanity eneegh to be dhe Pyesident of dhe Byaziwian Yepubwic.'
    > furrify('Oh, dreams, fleeing down the sinkhole...')
    'Oh, dyeams, fweeiyng down dhe siynkhowe...'