why i do for detect one string in a other string
example
j want find "toto" in an other string
if is good i do then
if is not good else
instr ? but i have bad response and it's no good
help please
thank
What you call a "chain" is called a "string" in English. I recommend that
you download the helpfile script56.chm from the Microsoft site. It gives you
a detailed explanation of the "instr" function, including a specific
example. If this does not suffice then you should post the code that does
not work for you.
Here's a simple example I threw together, how to use regular expressions
to find all occurrences of a string inside another string:
'###########################################
Set find = CreateObject("VBScript.RegExp")
With find
.Global = True
.IgnoreCase = True
.Pattern = "toto"
End With
testData = "-toto-Toto-tOto-toTo-totO-TOTO-"
Set finds = Find.Execute(testData)
For Each pos in finds
WScript.Echo pos.Value & " " & pos.FirstIndex
Next
Set finds = Nothing
Set find = Nothing
'###########################################
Output:
toto 1
Toto 6
tOto 11
toTo 16
totO 21
TOTO 26
--
.::[ Hz ]::.
"Pegasus [MVP]" <ne...@microsoft.com> wrote in message
news:eI6HpVLX...@TK2MSFTNGP04.phx.gbl...
Another useful bit of advise to the OP would be to suggest he include a copy
of the script that is giving a "bad response" so we would have a hope in
heck of being able to point out where he might have gone wrong.
/Al
Mmh. Isn't this what I suggested in my last sentence?
if instr(fullname, exeption) <> 0 then
wscript.echo fullname & " : EXEPTION, pas de traitement !!!!!!!!!"
else
wscript.echo fullname & " : traitement !!!!!!!!!"
end if
wend
________________________________________________________
thank you very much
"Hz" <h...@trashymail.com> a �crit dans le message de news:
%23BHOkXM...@TK2MSFTNGP04.phx.gbl...
I can't entirely follow the logic in your script but I note two problems:
- You reversed the position of the two arguments in your "instr"-function.
- You performed a binary rather than an ASCII comparison.
Try this modified script:
fichier_exeptions = "d:\test.txt"
sFullName = "c:\boot.ini"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set ofso_sansaccent_exeptions = oFSO.OpenTextFile(fichier_exeptions)
While Not ofso_sansaccent_exeptions.AtEndOfStream
sLine = ofso_sansaccent_exeptions.ReadLine
If InStr(1, sLine, sFullName, 1) > 0 Then
WScript.echo sLine & " : EXEPTION, pas de traitement !!!!!!!!!"
Else
WScript.echo sLine & " : traitement !!!!!!!!!"
End If
Wend
Memo to self: try to remember to read more closely before responding. My
apologies.
/Al
"Pegasus [MVP]" <ne...@microsoft.com> a �crit dans le message de news:
uSNv%23jXXK...@TK2MSFTNGP06.phx.gbl...
Thanks for the feedback.