pbh4dmin Posted September 18, 2009 Share Posted September 18, 2009 (edited) I need help with making a script that replace the 4th slash and the characters after it Example: http://google.com/happy/bd.html to http://google.com/happybirthday.html Thanks! Edited September 18, 2009 by pbh4dmin Link to comment Share on other sites More sharing options...
jvanegmond Posted September 18, 2009 Share Posted September 18, 2009 (edited) $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 September 18, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
pbh4dmin Posted September 18, 2009 Author Share Posted September 18, 2009 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 More sharing options...
dantay9 Posted September 19, 2009 Share Posted September 19, 2009 (edited) 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 September 19, 2009 by dantay9 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now