Jump to content

_ReplaceStringInFile wildcard


Recommended Posts

I have searched and I found one thing, but it didnt help me. I am wondering, can you use wildcards for it?

Example script.

$String = "xxxx"
_ReplaceStringInFile("ex.txt", $String, GUICtrlRead($Input))

The user can input anything so it will change the "xxxx" to say "1h4d", and then again to "hl8s".

Is that possable?

PS: I know it needs a GUI, its just an example.

Link to comment
Share on other sites

I have searched and I found one thing, but it didnt help me. I am wondering, can you use wildcards for it?

Example script.

$String = "xxxx"
_ReplaceStringInFile("ex.txt", $String, GUICtrlRead($Input))

The user can input anything so it will change the "xxxx" to say "1h4d", and then again to "hl8s".

Is that possable?

PS: I know it needs a GUI, its just an example.

No, _ReplaceStringInFile() does not have any wildcards.

You can read the whole file into a string (if less than about 100MB) and use StringRegExpReplace() for that.

:)

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
Link to comment
Share on other sites

This isnt really working for me. Maybe im just doing it wrong. When I try, to replace XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX with seri-lser-ials-eria-lser-ials-eria-lser it replaces each X with seri-lser-ials-eria-lser-ials-eria-lser. Any ideas?

Post what you tried.

:)

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
Link to comment
Share on other sites

MsgBox(0, "title", StringRegExpReplace("XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX", "[.?*]", "seri-lser-ials-eria-lser-ials-eria-lser"))

I have tryed \w, [X] (that wont replace the serial numbers if it needs to be changed).

Does the actual serial number contain only numbers or only alpha characters or a combination of both?

Edit: Your RegExp in the example is wrong anyway.

$sStr = StringRegExpReplace("XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX", "(.+)", "seri-lser-ials-eria-lser-ials-eria-lser")

Which is the same as using StringReplace()

Give us an actual example of what you want to do

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

MsgBox(0, "title", StringRegExpReplace("XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX", "[.?*]", "seri-lser-ials-eria-lser-ials-eria-lser"))

I have tryed \w, [X] (that wont replace the serial numbers if it needs to be changed).

This RegExp pattern finds eight groups of four characters each, separated by dashes:
Global $sString = "This is my serial number: 1A2B-3333-4C5D-6666-7E8F-9999-0G1H-2222, " & _
        "there are many like it, but this one is mine."
Global $sSerial = "seri-lser-ials-eria-lser-ials-eria-lser"

ConsoleWrite($sString & @LF)
$sString = StringRegExpReplace($sString, "(\w{4}-){7}\w{4}", $sSerial)
ConsoleWrite($sString & @LF)

:)

Edited by PsaltyDS
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
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...