×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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..

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 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: 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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close