Jump to content

stringregexpreplace


Champak
 Share

Recommended Posts

Simple problem...but can't get it. How can I use stringregexpreplace to remove a phrase within a sentence?

Ex.

$Test = "John went to town on monday"

I want to remove "John went to town". I don't want to use any of the functions to get the count and then trim, just want to use stringregexpreplace, and it has to work with none alphanumeric and numeric characters.

Thanks

Edited by Champak
Link to comment
Share on other sites

Is it always going to be the same part to remove? Like is it "John went to town." "John went to town on monday." "John went to town in his new car." etc?

Link to comment
Share on other sites

Yes, the $Test variable will always be different.....it will actually be '@ScriptDir & "\Folder\"' for my present needs. So everyones @ScriptDir will be different. And I figured I might as well ask my question in a generic way so I can apply it anytime I have the need for a similar situation.

Edited by Champak
Link to comment
Share on other sites

Yes, the $Test variable will always be different.....it will actually be '@ScriptDir & "\Folder\"' for my present needs. So everyones @ScriptDir will be different. And I figured I might as well ask my question in a generic way so I can apply it anytime I have the need for a similar situation.

Deleting something is just: $sString = StringRegExpReplace($sString, "RegExpHere", "")

But you have to tell it what to replace (with the RegExp). If you know it will be @ScriptDir, for example, it might be easier to just do: $sString = StringReplace($sString, @ScriptDir, "")

:mellow:

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...