Code: Select all
ab := "show these characters as normal characters :,!#¤%&/(()))=%`\'*-/+\.*?+[{|()^$"
adds := RegExReplace(ab, "", "")
msgbox, %adds%
return
Code: Select all
ab := "show these characters as normal characters :,!#¤%&/(()))=%`\'*-/+\.*?+[{|()^$"
adds := RegExReplace(ab, "", "")
msgbox, %adds%
return
Code: Select all
NewStr1 := RegExReplace(pe1, "\R", "``n")
NewStr2 := RegExReplace(NewStr1, "\t", "``t")
NewStr5 := RegExReplace(NewStr2, "\{", "(")
NewStr6 := RegExReplace(NewStr5, "\}", ")")
NewStr7 := RegExReplace(NewStr6, "#", "{#}")
NewStr8 := RegExReplace(NewStr7, "\|", "/")
NewStr9 := RegExReplace(NewStr8, "\+","{+}")
NewStr10 := RegExReplace(NewStr9, "\^", "{^} ")
NewStr11 := RegExReplace(NewStr10, "!", "{!}")
NewStr12 := RegExReplace(NewStr11, ";", "```;")
Code: Select all
NewStr := RegExReplace(NewStr, "\t", "``t")
NewStr := RegExReplace(NewStr, "\{", "(")
; etc
Code: Select all
SearchObject:={ "\R" : "``n"
, "\t" : "``t"
, "\{" : "("
, "\}" : ")"
, "\|" : "/"
, ";": "```;"
, "(#|\+|\^|!)" : "{$1}" }
for k, v in SearchObject
NewStr:=RegExReplace(NewStr,k,v)
alternative Method looks Nice, but how to describe ` part if I want get the same value? SearchObject:={ "" : ""}Guest wrote: Alternative method (you can write the object as one line, multiple lines here for readability:Code: Select all
SearchObject:={ "\R" : "``n" , "\t" : "``t" , "\{" : "(" , "\}" : ")" , "\|" : "/" , ";": "```;" , "(#|\+|\^|!)" : "{$1}" } for k, v in SearchObject NewStr:=RegExReplace(NewStr,k,v)
You don't need it at all, since replacing "anyvalue" by "thesamevalue" leaves the original string unchanged.euras wrote:alternative Method looks Nice, but how to describe ` part if I want get the same value? SearchObject:={ "" : ""}
Code: Select all
ab := abc := "show these characters as normal characters :,!#¤%&/(()))=%`\'*-/+\.*?+[{|()^$" ; make a copy of the string to search alongside the original
Pos=1 ; set the starting position for RegExMatch in the While loop
While Pos := RegExMatch(abc,"\W",m,Pos+StrLen(m)) ; while non-word characters are found in the copy of the original string
if !(m~="\s") && (ab~="\" m) ; if the found character is not a whitespace character and exists in the original string
MsgBox % (ab := RegExReplace(ab,"\" m)) ; remove it from the original string
return
Users browsing this forum: Aqualest, ComeOrDream and 363 guests