replace(). How do i grab the first 6 characters?

replace(). How do i grab the first 6 characters?

hi, im still new to jquery and i have a question.

i have a string but i only need to know the first 6 characters. Is there a way to do this?
Im thinking of using replace(), is there a better method?


  1. var  foldername = 'FOLDERLongAndRandomName';
  2. var regex = / NEED HELP HERE /;
  3. foldername = foldername.replace(regex,'');
in the end var foldername should be 'FOLDER'   only.


thanks in advance to anyone that can help me with this. Im pretty stuck, plus documentation on replace() expressions is really beyond my level at the moment.