Sign in to follow this  
Followers 0
tom13

Multiple String replace ?

3 posts in this topic

Hi,

I want to change ":", " ", "/", "\", """ into "."

For just 1 of those I do this:

StringReplace("tekst:is:here", ":", ".")

But how do I make sure that " ", "/", "\", """ get converted into "." too?

Thanks in advance :)

Share this post


Link to post
Share on other sites



AutoIt does regular expressions:

$String = 'A test string, this is: dir ..\temp /p "Test.txt"'
$ModString = StringRegExpReplace($String, '[:, /\"]', ".")
MsgBox(64, "Results", "Before:  " & $String & @CRLF & "After:  " & $ModString)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

AutoIt does regular expressions:

$String = 'A test string, this is: dir ..\temp /p "Test.txt"'
$ModString = StringRegExpReplace($String, '[:, /\"]', ".")
MsgBox(64, "Results", "Before:  " & $String & @CRLF & "After:  " & $ModString)

:D

Awesome :D:)

Edit:

I fixed it with this, but yours is alot alot cleaner :D

$dateraw = _DateTimeFormat( _NowCalc(),2)
$timeraw = _DateTimeFormat( _NowCalc(),5)

If StringInStr($dateraw, "/") Then
$date = StringReplace($dateraw, "/", ".")
ElseIf StringInStr($dateraw, "\") Then
$date = StringReplace($dateraw, "\", ".")
ElseIf StringInStr($dateraw, ":") Then
$date = StringReplace($dateraw, ":", ".")
Else
$date = $dateraw
EndIf
If StringInStr($timeraw, "/") Then
$time = StringReplace($timeraw, "/", ".")
ElseIf StringInStr($timeraw, "\") Then
$time = StringReplace($timeraw, "\", ".")
ElseIf StringInStr($timeraw, ":") Then
$time = StringReplace($timeraw, ":", ".")
Else
$time = $timeraw
EndIf
Edited by tom13

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