split(), left(), mid(), right(), something needed like this

I have a variable that basically houses all the fields I will display in an sql query.  Here is the variable for this example:

strFieldsToDisplay = "[INVOICE DETAILS].PART_#, INVENTORYMASTER1.[Mfg Name], INVENTORYMASTER1.Source, [CUSTOMER MASTER].[CUST NAME], [CUSTOMER MASTER].[CUST #], [INVOICE DETAILS].[CUST BUYER NAME], [INVOICE DETAILS].[INVOICE #], [INVOICE DETAILS].[CUST PO #], [INVOICE DETAILS].[CUST ITEM #], [INVOICE DETAILS].PRICE"

I am looking to create a function that will remove everything to the left of the ".".  So, example, [INVOICE DETAILS].PART_# would become PART_#.  The above variable, for end result, would look like this:

strFieldsToDisplay = "PART_#, [Mfg Name], Source, [CUST NAME], [CUST #], [CUST BUYER NAME], [INVOICE #], [CUST PO #], [CUST ITEM #], PRICE"

Any ideas on how to accomplish that?  Using .asp code.
dzirkelbAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gemartiCommented:
Maybe

First you would have to use the Split() function to seperate each part of the query where ever a comma occurs.

Then you would have to Split each element of that array to seperate each array element with a "."

For example ("split at each ','):
Split(""[INVOICE DETAILS].
PART_#, INVENTORYMASTER1.[Mfg Name], INVENTORYMASTER1.Source, [CUSTOMER MASTER].[CUST NAME], [CUSTOMER MASTER].[CUST #], [INVOICE DETAILS].[CUST BUYER NAME], [INVOICE DETAILS].[INVOICE #], [INVOICE DETAILS].[CUST PO #], [INVOICE DETAILS].[CUST ITEM #], [INVOICE DETAILS].PRICE", ",")


Give you an array with:

[INVOICE DETAILS].PART_#
INVENTORYMASTER1.[Mfg Name]
INVENTORYMASTER1.Source
[CUSTOMER MASTER].[CUST NAME]
[CUSTOMER MASTER].[CUST #]
[INVOICE DETAILS].[CUST BUYER NAME]
[INVOICE DETAILS].[INVOICE #]
[INVOICE DETAILS].[CUST PO #]
[INVOICE DETAILS].[CUST ITEM #]
[INVOICE DETAILS].PRICE


Then:
for each x array
Split(Array[x], ".")

would give you:


[INVOICE DETAILS]
PART_#
INVENTORYMASTER1
[Mfg Name]
INVENTORYMASTER1
Source
[CUSTOMER MASTER]
[CUST NAME]
[CUSTOMER MASTER]
[CUST #]
[INVOICE DETAILS]
[CUST BUYER NAME]
[INVOICE DETAILS]
[INVOICE #]
[INVOICE DETAILS]
[CUST PO #]
[INVOICE DETAILS][CUST ITEM #]
[INVOICE DETAILS]
PRICE
 

Then you would just concatenate all the odd numbered array2 values since array's start counting a 0.



0
gemartiCommented:
Here you go:

'Declare variable
Dim i, text, token, token2, newStr
'store string
text = "[INVOICE DETAILS].PART_#, INVENTORYMASTER1.[Mfg Name], INVENTORYMASTER1.Source, [CUSTOMER MASTER].[CUST NAME], [CUSTOMER MASTER].[CUST #], [INVOICE DETAILS].[CUST BUYER NAME], [INVOICE DETAILS].[INVOICE #], [INVOICE DETAILS].[CUST PO #], [INVOICE DETAILS].[CUST ITEM #], [INVOICE DETAILS].PRICE"
'create array
token = split(text,",")
For i = 0 To 9
  wscript.echo i & token(i)
  wscript.echo " "
  token2 = split(token(i), ".")
    newStr = newStr & "," & token2(1)
   
Next


wscript.echo newStr
0
gemartiCommented:
Actually this is better:

'Declare variable
Dim i, text, token, token2, newStr
text = "[INVOICE DETAILS].PART_#, INVENTORYMASTER1.[Mfg Name], INVENTORYMASTER1.Source, [CUSTOMER MASTER].[CUST NAME], [CUSTOMER MASTER].[CUST #], [INVOICE DETAILS].[CUST BUYER NAME], [INVOICE DETAILS].[INVOICE #], [INVOICE DETAILS].[CUST PO #], [INVOICE DETAILS].[CUST ITEM #], [INVOICE DETAILS].PRICE"
token = split(text,",")
For i = 0 To 9
  wscript.echo i & token(i)
  wscript.echo " "
  token2 = split(token(i), ".")
    newStr = newStr & "," & token2(1)
   
Next

wscript.echo newStr
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dzirkelbAuthor Commented:
Thanks for your suggestions guys!  I mixed both of your thoughts together to come up with the following function:

Function StripTableName(strData)
      strData = strFieldsToDisplay
      arrayOutputData = Split(strData, ", ")
      intArrayOutputDataCount = uBound(arrayOutputData, 1)
      
      for i = 0 to intArrayOutputDataCount
            arrayOutputDataTemp = Split(arrayOutputData(i), ".")
            
            if i = intArrayOutputDataCount then
                  strOutputData = strOutputData & arrayOutputDataTemp(1)
            else
                  strOutputData = strOutputData & arrayOutputDataTemp(1) &", "
            end if
      next
      
      StripTableName = strOutputData
End Function
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.