from
str1 := "dab/c/dco" str2 := "dabc|d|co"i wanna get
newstr := "dab/c|/d|co"
Posted 18 October 2012 - 05:39 AM
str1 := "dab/c/dco" str2 := "dabc|d|co"i wanna get
newstr := "dab/c|/d|co"
Posted 18 October 2012 - 05:55 AM
str1 := "dabc|d|co" RegExMatch(str1, "dab(c\||/c/)(d\||d)co", _) MsgBox, %_%
Posted 18 October 2012 - 08:14 AM
Posted 18 October 2012 - 08:17 AM
I'm starting to think you are a bot - That is your standard response to everything.thanks, use RegExReplace, not use loop, please
Posted 18 October 2012 - 08:51 AM
Posted 18 October 2012 - 11:17 AM
str1 := "dab/c/dco" str2 := "dabc|d|co" newstr := "dab/c|/d|co"
Posted 18 October 2012 - 11:38 AM
Posted 18 October 2012 - 12:03 PM
[color=#000080]str := "dabc|d|co" MsgBox % RegExReplace(str,"(?:c|d)\|","/$0") [color=#00BF00]; or[/color] str := "dab/c/dco" MsgBox % RegExReplace(str,"/(?:c|d)","$0|")[/color]
Posted 18 October 2012 - 12:28 PM
thanks, nice, but my example isnt clear enough, i change it like[color=#000080]str := "dabc|d|co" MsgBox % RegExReplace(str,"(?:c|d)\|","/$0") [color=#00BF00]; or[/color] str := "dab/c/dco" MsgBox % RegExReplace(str,"/(?:c|d)","$0|")[/color]
str1 := "dabc/dco/c" str2 := "dabc|d|coc" newstr := "dabc|/d|co/c"
Posted 18 October 2012 - 12:34 PM
That is because you are always too vague.thanks, nice, but my example isnt clear enough, i change it like
Posted 18 October 2012 - 12:37 PM
Posted 18 October 2012 - 01:01 PM
str1 := "dabc/dco/c" str2 := "dabc|d|coc" newstr := "dabc|/d|co/c"str1 consists of "dabcdcoc" and "/".
Posted 18 October 2012 - 01:25 PM
Can not be done without analysing the strings...I mean two more regexp to make it, not just one regexp to make it
Posted 18 October 2012 - 04:17 PM
[color=#000080]str1 := "dabc/dco/c" , str2 := "dabc|d|coc" , sort := RegExReplace(RegExReplace(str1,"\W"),"\w(?=\w)","$0,") [color=#00BF00];sort out only the letters in the sequence of 'str1'[/color] Sort, sort, U D`, [color=#00BF00]; remove all duplicate letters[/color] Loop, parse, sort, `, [color=#00BF00]; parse through each letter in 'str1'[/color] if InStr(str1,"/" A_LoopField) [color=#00BF00]; if the letter is in 'str1' with a preceding slash[/color] While Pos := InStr(str1,A_LoopField,0,1,A_Index) [color=#00BF00]; find out which occurrence of the letter it is[/color] if SubStr(str1,Pos-1,2) = "/" A_LoopField i := InStr(str2,A_LoopField,0,1,A_Index), str2 := SubStr(str2,1,i-1) "/" SubStr(str2,i) [color=#00BF00]; splice the slash into 'str2' based on the character's occurrence in 'str1'[/color] MsgBox % str2[/color]