Sign in to follow this  
Followers 0
pbh4dmin

Replace 4th slash and after characters

4 posts in this topic

#1 ·  Posted (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 by pbh4dmin

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by Manadar

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
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
Sign in to follow this  
Followers 0