Select to view content in your preferred language

What is the wildcard for VBscript?

11262
3
Jump to solution
11-03-2014 07:19 AM
DanielAmrine
Frequent Contributor

I have a simple code example for catching values of the name name that have some values that are capitalized and some that are lower case:

 

  1. Dim X
  2. If InStr( [Reservoir],"bARNETT" ) OR InStr([Reservoir],"BARNETT") Then
  3. X = "BARNETT SHALE"
  4. else
  5. X = ""
  6. end if
  7. Expression = X

 

I would like to use a wildcard so I don't have to use the Or Statement. In the interest of standardizing oil and gas reservoir names for spatial analysis there has to be a quicker way then writing long "AND" "OR" arguments.

 

This is in VBscript because I couldn't see the "InStr" function or  a function like it in the python examples.

 

I tried the following:

  1. Dim X
  2. If InStr( [Reservoir],"%ARNETT" ) Then
  3. X = "BARNETT SHALE"
  4. else
  5. X = ""
  6. end if

And it didn't work.

 

As always any help is much appreciated!

0 Kudos
1 Solution

Accepted Solutions
RichardFairhurst
MVP Honored Contributor

If the only variation you are trying to capture is due to capitalization differences, the standard approach is to use UCASE or LCASE on all parts of the equation (unless you type the word and know the case).  So for your example use:

If InStr( UCASE([Reservoir]),"BARNETT" ) Then

The Instr function does not support wildcards.

View solution in original post

0 Kudos
3 Replies
RichardFairhurst
MVP Honored Contributor

If the only variation you are trying to capture is due to capitalization differences, the standard approach is to use UCASE or LCASE on all parts of the equation (unless you type the word and know the case).  So for your example use:

If InStr( UCASE([Reservoir]),"BARNETT" ) Then

The Instr function does not support wildcards.

0 Kudos
DanielAmrine
Frequent Contributor

Richard,

That was an angle I didn't think of. This will work for any string field with capitalization problems. I appreciate the direction on using the nested function. 

However, i would still like to know what the wildcard is in VbScript. i tried "%" but that didn't seem to be the right one. (Maybe % is python wildcard)

I can use the wildcard for fields that have misspellings or abbreviated reservoir names. The Vicksburg is a good example because some companies report it as VICKSBURG, others VXBG, or VX, or VKBG, VCKBG....etc... I tracked down each one and used "OR" statements but with a wildcard you could simplify the string. I Hope you could devise an InStr that sraches for the fields that contain V,X,K,B, and G this would catch all the fields with "Vicksburg" and variations of it.

0 Kudos
RichardFairhurst
MVP Honored Contributor

You have to use Regular Expressions (regex) to do pattern matching.  See this post for some discussion on the subject and some links to regex help.  Regex can be a bit obscure to figure out and I am no expert in using it.

0 Kudos