Javascript String GetNameWithoutSuff()

Description

Javascript String GetNameWithoutSuff()


'use strict';//from   ww w . j a  v  a  2  s  .  c om

String.prototype.GetNameWithoutSuff = function() {
 let str = this.toString();
 let nameRegex = /([^/\\]+)\.[a-zA-Z]+$/;
 let match = str.match( nameRegex );
 if ( !match || match.length === 0 ) {
  return '';
 }
 return match[1];
};



PreviousNext

Related