Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some help/advice please - search/edit multiple strings on same line

Status
Not open for further replies.

PaulSc

MIS
Aug 21, 2000
148
GB
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..

Code:
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
 
I just had to do something similar, had to search through some text files, look for dates that were in the format of Jan 1, 2015 and replace all instances of that date format with something like 1/1/2015.

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


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
Work SMARTER not HARDER.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top