I am still fairly new to the VBScript environment. Anyhow, I need some help in determining if there are any functions that can determine if a particular string has X number of characters or symbols.
For example: I have string that contains "Today is ******* good". How do I determine X number of "*" in the string. I know that I can use the "Split" method to break up the words and then use the "InStr" method to determine "*" X position of the character. It does count but it can't give me the exact number of "*".
Any help would be good.
String manipulation
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
String manipulation
I am still fairly new to the VBScript environment. Anyhow, I need some help in determining if there are any functions that can determine if a particular string has X number of characters or symbols.
For example: I have string that contains "Today is ******* good". How do I determine X number of "*" in the string. I know that I can use the "Split" method to break up the words and then use the "InStr" method to determine "*" X position of the character. It does count but it can't give me the exact number of "*".
Any help would be good.
For example: I have string that contains "Today is ******* good". How do I determine X number of "*" in the string. I know that I can use the "Split" method to break up the words and then use the "InStr" method to determine "*" X position of the character. It does count but it can't give me the exact number of "*".
Any help would be good.
String manipulation
Here is the code. This code keeps giving me back a position 3 even though I use position 3 to search for. If I was to increment the search start position, it returns nothing for me. I am a little confused.
I know it is not necessary to split up the words but to make it easier, I split the string up.
newguy792007-05-23 10:07:28
I know it is not necessary to split up the words but to make it easier, I split the string up.
Code: Select all
Dim totalNumberOfCellsOnPartitionArray(1, 7) '2 Dimensional array - First dimension is for Cabinets and Second dimension is for Cell Slots
searchTextArray = "Part 1 |..**|"
For r = 0 to 1
For c = 0 to 7
totalNumberOfCellsOnPartitionArray(r, c) = False
Next
Next
splitTextArray = Split(searchTextArray, "|", -1, 1)
cellPositionFound = 0
cellPositionFoundTemp = 0
cabinetIndex = 0
For splitIndex = 0 to UBound(splitTextArray)
cellPositionFound = Instr(1, splitTextArray(splitIndex), "*", 1)
While cellPositionFound 0
lenTest = Len(splitTextArray(splitIndex))
totalNumberOfCellsOnPartitionArray(cabinetIndex, cellPositionFound - 1) = True
cellPositionFoundTemp = Instr(cellPositionFound, splitTextArray(splitIndex), "*", 1)
If cellPositionFound cellPositionFoundTemp Then
cellPositionFound = cellPositionFoundTemp
Else
cellPositionFound = 0
End If
Wend
Next
String manipulation
I just ran into the same need last week so it was fresh in my head.
There are many other methods but that is the esiest and probably teh most efficient.
Regular expression are actualy more powerful but need a liitle learning curve.
There are many other methods but that is the esiest and probably teh most efficient.
Regular expression are actualy more powerful but need a liitle learning curve.