I have a working function in JS
function countWords(s){
s = s.replace(/(^\s*)|(\s*$)/gi,""); //modified trim function
s = s.replace(/[ ]{2,}/gi," ");
s = s.replace(/\n /,"\n");
return s.split(' ').length;
}
The problem is when i change to ASP, it seems not working:
Sub formatText(a)
a = Replace("/(^\s*)|(\s*$)/gi",a,"")
a = Replace("/[ ]{2,}/gi",a,"")
a = Replace("/\n /",a,"\n")
return a
End Sub
It return nothing from the function, how to fix the problem? thanks
Changed to
'regEx initialization
Dim regEx
set regEx = New RegExp 'Creates a regexp object
regEx.IgnoreCase = True 'Set case sensitivity
regEx.Global = True 'Global applicability
'trim input text
Sub formatText(a)
a = Replace("(^\s*)|(\s*$)",a,"")
a = Replace("[ ]{2,}",a,"")
regEx.IgnoreCase = False 'Set case sensitivity
regEx.Global = False 'Global applicability
a = Replace("\n ",a,"\n")
return a
End Sub
still no luck please help..