Some help/advice please - search/edit multiple strings on same line
Some help/advice please - search/edit multiple strings on same line
(OP)
Hi I wonder if I can as some advice/get some assistance please...
i have a script which runs through a folder of 1000's of static html pages, looks for a specific piece of data and then changes it (after some subsequent work) to another value..
its actually a <a or <src link to a graphic file, however the url contains a dynamically generate GUID...
Anyway it all works perfectly finding and replacing the data as required bar in one set of circumstances and I just cant fund anything (so far) that may help.
As the html code is compressed a "line" may actually contain multiple links and my script only processes the 1st occurrence..
So Im after some pointers as to how to check whether the line I'm processing has mukltiple "xxxx/yyyy/z" strings and then update each one...
Cheers
i have a script which runs through a folder of 1000's of static html pages, looks for a specific piece of data and then changes it (after some subsequent work) to another value..
its actually a <a or <src link to a graphic file, however the url contains a dynamically generate GUID...
Anyway it all works perfectly finding and replacing the data as required bar in one set of circumstances and I just cant fund anything (so far) that may help.
As the html code is compressed a "line" may actually contain multiple links and my script only processes the 1st occurrence..
CODE --> vbscript
do while oInfile.AtEndOfStream <> True stLine = oInfile.readline a1=CINT(InStr(1,stLine,"/xx/yyyyyyyyy/z",VbTextCompare)) ' If Image link found find end of GUID if a1 > 0 then b1=CINT(InStr(a1+15,stLine,"/")) c1=CINT((b1-a1)-12) d1=Mid(stLine,a1+13,c1) ' next check if link contains an param value e1=CINT(InStr(1,stLine,"param=")) ' If found extract all params to end of EndOfTag if e1 > 0 then 'Found a continuation parameter so look for EndOfTagas end of string f1=CINT(InStr(e1+1,stLine,"EndOfTag=True")) g1=Mid(stLine,e1-1,f1-e1+13) else ' otherwise do nothing g1="" end if
So Im after some pointers as to how to check whether the line I'm processing has mukltiple "xxxx/yyyy/z" strings and then update each one...
Cheers
RE: Some help/advice please - search/edit multiple strings on same line
I think you will find this task is easier to accomplish in PowerShell. You can search for your GUID using a regular expression, then use the PowerShell -Replace option to alter that path and write it back to the file.
See if this helps you any:
thread1619-1745201: Stumped by -Replace with RegEx
I hope that helps.
Regards,
Mark
No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.
Check out my scripting solutions at http://www.thespidersparlor.com/vbscript
Work SMARTER not HARDER.