EXAMPLE VBScripts for Capture and Index Manipulation
Here’s a good VBScript reference site:
https://www.w3schools.com/asp/asp_ref_vbscript_functions.asp
Some example VBScripts and their usage are given below:
This script replaces the digits '88' with '99', assuming '88' is the value
fetched by the indexing process.
Replace(Value,"88","99")
This script reverses the value fetched by the indexing process.
StrReverse(Value)
This script converts to uppercase the value fetched by the indexing process.
UCase(Value)
This script picks the first five characters, including numbers, from the value
fetched by the indexing process.
Left(Value,5)
This script picks the characters to the left of a “/”
Left(Value, InStr(Value, "/")-1)
Example: Changes 6170160/1 to 6170160
This script captures the 5 characters starting from the right.
Right(Value,5)
Example: Changes 123456 to 23456
- Replace(Value," ","")
- This script removes spaces “ “ from a string
- Example: Changes this VIN #: 5TDD G RFHXH S02 7889 to 5TDDGRFHXHS027889
- Replace(Replace(Replace(Replace(Replace(Value, "-",""), "_", "" ), ",", "" ),".","")," ","")
- This script removes the following characters from a string: “-“, “_”, “,”, “.” and a space “ “
- Example: Changes this __123456 to 123456
- Example: Changes this -123456 to 123456
- Example: Changes this .,123456 to 123456
- “ABC-“ & Value
- Add (concatenate) a string to a value
- Example: Changes this 123456 to ABC-123456
- Replace(FormatNumber(Replace(Value, "/", ""), 0, vbFALSE), ",", "")
- Remove leading 0’s and remove slashes / in a date.
- Example: Changes this 02/21/17 with 22117
- Right(Replace(Replace(Replace(Replace(Replace(Value, "-",""), "_", "" ), ",", "" ),".","")," ",""),5)
- Replace(Value, chr(34),"")
- This script replaces a double quote “ with a null value.
- Example: Changes this “47125 to 47125
- chr(34) is the character code for a double quote. You could also use replace(value, """", "") that """" gets evaluated as one double-quote character, but I believe the chr(34) is much less confusing.
- This script replaces a double quote “ with a null value.
- Replace(Replace(Replace(Replace(Replace(Replace(Value, "-",""), "_", "" ), ",", "" ),".","")," ",""),chr(34), “”)
- This script removes the following characters from a string: “-“, “_”, “,”, “.” and a space “ “ and the double quote “ with a null value.
- Trim(Value)
- trim(Split(Value, ",")(1))
- This will create an array out of th comma-separated parts of a text string, then access either the first or second part.
- trim(Split(Value, ",")(numberhere))
- this would be a good VBsript to separate a last name, first name
- Example String: Burnett, Carol
- trim(Split(Value, ",")(0))
- Will return the first value before the comma which is Burnett
- trim(Split(Value, ",")(1))
- Will return the value after the first comma which is Carol
- Remove leading 0’s and remove slashes / in a date.
- Add (concatenate) a string to a value
- This script removes the following characters from a string: “-“, “_”, “,”, “.” and a space “ “
- This script removes spaces “ “ from a string
RO Number
Replace(Left(Value, InStr(Replace(Value,"~","-"),"-")-1)," ","")
Name
Name
Replace(Replace(Replace(Replace(Value,"\",""),"-",""),"Commercial ",""),"Commercial","")
VIN
Left(Replace(Replace(Value," ",""),"VIN:",""),17)
Left(Replace(Replace(Replace(Replace(Value," ",""),"VIN:",""),"/","1"),".",""),17)
Cell Number
Left(Replace(Replace(Value,"~","-"),"?","7"),12)
Year
Year(value)
Week
datepart("ww",Value)
If you want an index field to be equal to today's date, select [Value} for the Zone Type and put any value but I recommend using "Today" as the [Keyword] and use the following script to change the value in the keyword cell to today's date.
Extract Year from date
Right(Replace(Replace(Replace(Value,"O","0"),"I","1"),"B","8"),4)
Replace common letters to numbers
Replace(Replace(Replace(Value,"O","0"),"I","1"),"B","8")
Extract the characters to the right of the “-“ symbol.
The script below will extract “Carol Burnett” from “16557 – Carol Burnett”.
Right(Value,Len(Value)-InStr(Value,"-")-1)
I should mention that the scripts below work when the string you want to manipulate is in the format of: FirstName{space}Last Name
For example, the script below will turn JoHn SMitH to Smith, John
RETURNS PROPER LAST NAME, PROPER FIRST NAME
mid(value,(instr(value," ")+1),1) & LCase(right(value,Len(value)-(instr(value," ")+1))) & ", " & UCase(Left(value,1)) & LCase(MID(VALUE,2,(instr(value," ")-2)))
Various VBScripts Examples for FileBound Capture
UCase(Left(value,1)) & LCase(Right(value,Len(value)-1))
Ucase(left(value,1)) & Lcase(right(value,instr(value," ")-2))
RETURN POSITION # STRING IS FOUND
Instr(value," ")
RETURNS VALUE AFTER 1st SPACE
mid(value,(instr(value," ")+1),1)
RETURNS PROPER FIRST NAME
UCase(Left(value,1)) & LCase(MID(VALUE,2,(instr(value," ")-2)))
RETURNS PROPER LAST NAME
mid(value,(instr(value," ")+1),1) & LCase(right(value,Len(value)-(instr(value," ")+1)))
RETURNS PROPER LAST NAME, PROPER FIRST NAME
mid(value,(instr(value," ")+1),1) & LCase(right(value,Len(value)-(instr(value," ")+1))) & ", " & UCase(Left(value,1)) & LCase(MID(VALUE,2,(instr(value," ")-2)))