Here is the ASP code:
CONST C_prefix = "contains(.,'"
CONST C_midfix = "') or contains(.,'"
CONST C_suffix = "')"
Function CreateContainsList( fromStr )
Dim temp, re
' the regexp ensures that multiple spaces become single spaces
Set re = New RegExp
re.Pattern = "\s+"
re.Global = True
' so get an array of words via split...
temp = Split( re.Replace( Trim(fromStr), " " ), " " )
' and make it into the contains list via join and helpers
CreateContainsList = C_prefix & Join( temp, C_midfix ) & C_suffix
demo = " My Little Black Book "
path = "form/document[" & CreateContainsList(demo) & " ]//*"
Response.Write "<pre>" & demo & "" & path & "</pre>"
I tried like this but the demo does not print out.