Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;Test-StrSubWild.wbt data = "AutoSampler Report Table Name: STL Autosampler Type: TYPE TJA Set# Type Prepare? Description Method #Pos Rack# StartPos1 Normal No P40207A 48 2 1" pos = StrIndexWild(data, "P?????", 1) ret = StrSubWild(data, "P?????", pos) Message("StrSubWild result", ret) ExitExample --> P?????? would find the first 'P' regardless of case. And it will include spaces. I need to find a string in this format: "P40207A".
#DefineFunction SimpleRegEx( myString, myExpression, ignoreCase ) regex = ObjectCreate("VBScript.RegExp") ; Creates a regular expression object for use by WinBatch. regex.Pattern = myExpression ; Required to establish a regular expression pattern to use in searching. regex.IgnoreCase = ignoreCase ; Optional, but required by this user defined function. If regex.Test(myString) == 0 ; Set default return values if search string was not found. index = -1 position = 0 value = "" length = -1 Else objCollection = regex.Execute(myString) ; This initiates the object collection of the regular expression object. (!) henum = ObjectCollectionOpen(objCollection) ; OK. Start match = ObjectCollectionNext(henum) index = match.FirstIndex ; 0 based index. Note that WIL variables are indexed at 1. Arrays are indexed at 0. position = index + 1 value = match.Value length = match.Length ObjectCollectionClose(henum) Endif list = StrCat(value,@TAB,position,@TAB,length) ; Position is the normal WIL use based on 1 as the first character. ObjectClose(regex) Return list #EndFunction data = "AutoSampler Report Table Name: STL Autosampler Type: TYPE TJA Set# Type Prepare? Description Method #Pos Rack# StartPos1 Normal No P40207A 48 2 1" regstr = "P\d{5}[A-Z]" ret = SimpleRegEx(data,regstr,@false) value = ItemExtract(1, ret, @tab) Message("Search result", value) Exit
Article ID: W17284
File Created: 2007:07:03:14:29:20
Last Updated: 2007:07:03:14:29:20