Monday Mini-Golf #6: Meeesesessess upp teeexexextext

Retina, 43 bytes

.(?<=[^_\W]([^_\W]+))(?<=(\1)(?<=\D))?
$1$2

Run the code from a single file with the -s flag. Since this is just a single regex substitution, you can test it here (click the Context tab to see the results).

Explanation

This matches any digit and letter which is not the first in a run. While . can match any non-linefeed character, the lookbehinds ensure the other conditions:

(?<=[^_\W]([^_\W]+))

This matches backwards from the position after the .. First it matches one or more alphanumeric characters and captures them into group 1 with ([^_\W]+). This immediately ensures that the . corresponds to an alphanumeric character itself. Then the additional [^_\W] makes sure that there is one more alphanumeric character in the current run, which we don't include the match. Now group 1 is what we want to replace the match with if it is a digit - if it is a letter we want to replace it with twice this string. That's where the second lookbehind comes into play:

(?<=(\1)(?<=\D))?

This one is optional, so if it fails it won't affect the match at all. It first ensures that the . was not a digit via (?<=\D) - so this lookbehind is only relevant when we're matching letters. In that case, we match group \1 once more (this always matches, because we've captured the group from the same position), but capture it into group 2.

Hence, we simply replace the regex with the contents of both groups ($1$2). If the match was a digit, $2 will still be empty and we write back the prefix only once. If it was a letter, $2 is the same as $1 and we write it back twice.


JavaScript(ES6) 82

Using the regexp optimization suggested by Mwr247

s=>s.replace(/([\W_])|./g,(x,y)=>y?(f=0,x):f?(p+=x,p+(-x-1?z:p)):(p=z,f=x),f=z='')

Test running the snippet below in any recent browser

F=s=>s.replace(/([\W_])|./g,(x,y)=>y?(f=0,x):f?(p+=x,p+(-x-1?z:p)):(p=z,f=x),f=z='')

// document.write(F(prompt('Insert string')))

// TEST
console.log=x=>O.innerHTML+=x+'\n'

function test()
{
  O.innerHTML=F(I.value)
}

;[
 ['Mess up text','Meeesesessess upp teeexexextext']
,['This is some longer text.',
  'Thhhihihishis iss sooomomomeome looononongongongeongeongeronger teeexexextext.']
,['CAPS LOCK && "Punc-tua"+\'tion\'',
  'CAAAPAPAPSAPS LOOOCOCOCKOCK && "Puuunununcunc-tuuuaua"+\'tiiioioionion\'']
,['CaPs wItHIn loWERs'
  ,'CaaaPaPaPsaPs wIIItItItHItHItHIItHIItHInItHIn loooWoWoWEoWEoWERoWERoWERsoWERs']
,['1337 numb3r5','1333337 nuuumumumbumbumb3umb3rumb3rumb3r5']
,['abcdefghij 0123456789'
 ,'abbbcbcbcdbcdbcdebcdebcdefbcdefbcdefgbcdefgbcdefghbcdefghbcdefghibcdefghibcdefghijbcdefghij 0112123123412345123456123456712345678123456789']
,['Code-golf is the best!'
  ,'Cooodododeode-gooolololfolf iss thhhehe beeesesestest!']
].forEach(t => (
  i=t[0],x=t[1],r=F(i),
  console.log('Test ' + (r==x?'OK':'Fail')+'\nInput:  '+i+'\nResult: '+r+'\nCheck:  '+x+'\n')
))
#I { width: 50% }
Your test<input id=I><button onclick="test()">-></button>
<pre id=O></pre>


JavaScript (ES6), 92 88 87

f=>f.replace(/[^_\W]+/g,m=>m[0]+[...m].slice(1).reduce((a,e)=>a+=(y+=e,++e?y:y+y),y=''))

I have no idea how to golf this down...

Thanks Mwir247 for the golfed down regex and ETHproductions for one byte golf in reduce function.