RegEx "searchforward" replacement possible?
Posted: Tue Feb 12, 2002 2:42 pm
This is the first time I've tried something like this, and Ihaven't a clue how to do it (or even if it is possible in TextPad).
I have several script subroutines which use an echo statement; I want to turn them all into functions which return a value instead of echoing it, which means as one step I need to look for
sub _somestring_
then search forward from there for the first following line which has the string
wscript.echo
and replace that second string with this:
_somestring_ =
Here's an example - note that I'm not worrying about the "sub" word itself on this pass, that part is easy.
BEFORE SUBSTITUTION
''''''''''''''''''''''''''''''''''
Sub DispMinPassLength(strDomain)
Dim Computer
Set Computer= GetObject("WinNT://" & strDomain)
wscript.echo Computer.MinPasswordLength
End Sub
''''''''''''''''''''''''''''''''
AFTER SUBSTITUTION
''''''''''''''''''''''''''''''''
Sub DispMinPassLength(strDomain)
Dim Computer
Set Computer= GetObject("WinNT://" & strDomain)
DispMinPassLength = Computer.MinPasswordLength
End Sub
''''''''''''''''''''''''''''''''
and then I can do a pass to swap the word "Sub" into "Function".
Any way to do this? I think it's called "anchoring"....
I have several script subroutines which use an echo statement; I want to turn them all into functions which return a value instead of echoing it, which means as one step I need to look for
sub _somestring_
then search forward from there for the first following line which has the string
wscript.echo
and replace that second string with this:
_somestring_ =
Here's an example - note that I'm not worrying about the "sub" word itself on this pass, that part is easy.
BEFORE SUBSTITUTION
''''''''''''''''''''''''''''''''''
Sub DispMinPassLength(strDomain)
Dim Computer
Set Computer= GetObject("WinNT://" & strDomain)
wscript.echo Computer.MinPasswordLength
End Sub
''''''''''''''''''''''''''''''''
AFTER SUBSTITUTION
''''''''''''''''''''''''''''''''
Sub DispMinPassLength(strDomain)
Dim Computer
Set Computer= GetObject("WinNT://" & strDomain)
DispMinPassLength = Computer.MinPasswordLength
End Sub
''''''''''''''''''''''''''''''''
and then I can do a pass to swap the word "Sub" into "Function".
Any way to do this? I think it's called "anchoring"....