Jump to content

Replace 4th slash and after characters


pbh4dmin
 Share

Recommended Posts

$in = "http://google.com/happy/bd.html"

$n = StringInStr($in,"/", 0, -1)
$mid = StringLeft($in, $n-1)

$out = $mid & "birthday.html"

ConsoleWrite($out & @CRLF)

Being able to do simple string operators is vital in your job as a programmer. I see you're probably a system admin, or something, but this is basic knowledge.

Edited by Manadar
Link to comment
Share on other sites

Thank you for your help. I understand AI a little bit better now. However, would you kindly help me with one more? I need the script to be able to open a text file name I provide.. Then, find the 1st slash from the right and whatever characters are on the right in each line of URLS and replace them with the string I provide (exactly from the last example but with multiple URLS).. Then replace a second string in the front from "http://" to "http://www." Finally, save the file with the output as the original file. I've tried it but I don't know how to replace multiple URLS, just one. Please help. Thank you!

Link to comment
Share on other sites

What have you tried? Please post your failed script so the people on the forum can help you fix your script. You won't learn anything by having it done for you (and probably no one would do it for you).

You need to look up StringInStr(), StringRight(), StringLeft(), StringMid(), and StringReplace() for a start on your parsing. For the file, try FileOpen(), FileRead(), FileReadLine(), FileWrite(), and FileClose().

Edited by dantay9
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...