I have a CSV with character sets that I need to replace.
These characters are link the following:
amaxb7568bj
amaxj74tyl9
amaxk74r98z
amaxy74jzs8
amaxs74fjt5
amaxp74cd6t
amax4744bnr
amaxk74fygz
amaxv747crm
amaxu747vd2
amaxj749hjy
amaxg74brvl
amaxf74bglr
amaxx77l8ls
So... they start with 'amax' and then are followed by 7 more characters.
This will always be the same pattern.
I want to delete all occurrences of these words (leave all other text as is).
I'd like to do 2 ways.
1. Open the file in a text editor and replace all occurrences with nothing, i.e. delete.
and
2. Open a CSV read in and replace all and output the text in the CSV and save the same file.
Not sure where to start. Assuming I need regex? I never got to grip with regex in AHK. It seems to be a little different than elsewhere in other languages (or am I wrong in saying that?)
Looking for help starting off.
Assuming I cant use a simple string replace.
Thanks.
Need help replacing a pattern of characters
Re: Need help replacing a pattern of characters
Code: Select all
str =
(
not,amaxb7568bj,this
not,amaxb756,this
notamaxj74tyl9this
notamaxj74tyl9thisorthatortheother
notamaxj74tyl9thisorthatortheother,done
)
Clipboard =
Clipboard := RegExReplace(str, "amax[^,\n]{7,}")
ClipWait, 2
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
MsgBox, 64, Results, %Clipboard%
Re: Need help replacing a pattern of characters
Very nice
Could you explain the code for me?
"amax[^,\n]{7,}"
What are the ^ , \n characters?
What does the {,7} do? I'm guessing it says amax + 7 characters?
ALSO:
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
MsgBox, 64, Results, %Clipboard%
What does the 48 and 64 do?
Thanks.
Could you explain the code for me?
"amax[^,\n]{7,}"
What are the ^ , \n characters?
What does the {,7} do? I'm guessing it says amax + 7 characters?
ALSO:
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
MsgBox, 64, Results, %Clipboard%
What does the 48 and 64 do?
Thanks.
Re: Need help replacing a pattern of characters
Thanks
I'll read up more from your links and will try the code
I'll read up more from your links and will try the code
Who is online
Users browsing this forum: Lamron750 and 383 guests