Hi All,

i'm trying to use regular expressions to filter lines from an input text
file and write to an output

I am looking for lines containing the "Y" character


here is the code part:

...
If myString = "*Y*" Then

OutputFile.WriteLine myString

End if
...


But it looks like this is loking for a match where the star "*"
character is considered as a charcater and not as a wildcard?

Re: string match with regular expressions by Paul

Paul
Sun Sep 02 08:33:12 PDT 2007


"console1" <console1@nospam.console1.org> wrote in message
news:fbej94$h1e$1@aioe.org...
>
> Hi All,
>
> i'm trying to use regular expressions to filter lines from an input text
> file and write to an output
>
> I am looking for lines containing the "Y" character
>
>
> here is the code part:
>
> ...
> If myString = "*Y*" Then
>
> OutputFile.WriteLine myString
>
> End if
> ...
>
>
> But it looks like this is loking for a match where the star "*" character
> is considered as a charcater and not as a wildcard?

If you really want to use regular expressions, you need to use the regular
expression object. I think in this particular case, you are looking for
lines that start with an upper case 'Y'. That is more easily done using the
Left() function.

If Left(myString, 1) = "Y" Then
OutputFile.WriteLine myString
End If

Download the scripting help file; it has lots of sample code for almost
every built-in VBScript function. Microsoft's web site has a very nice
scripting center, which you should be able to easily find through
msdn.microsoft.com by searching for one word: scripting.

-Paul Randall



Re: string match with regular expressions by Ayush

Ayush
Sun Sep 02 11:24:24 PDT 2007

[console1] wrote-:

> Hi All,

> i'm trying to use regular expressions to filter lines from an input text
> file and write to an output

> I am looking for lines containing the "Y" character


> here is the code part:

> ....
> If myString = "*Y*" Then

> OutputFile.WriteLine myString

> End if

If InStr(myString,"Y") Then
OutputFile.WriteLine myString
End if

Good Luck, Ayush.
--
Scripting Home : http://snipurl.com/Scripting_Home