symadis Posted May 28, 2010 Share Posted May 28, 2010 Hi, I'm moving a php script to autoit. I have a variable, and I want to replace all the specials characters inside. I have this working from php : $title="Strômß" $search = explode(",","Š,Œ,Ž,š,œ,ž,Ÿ,¥,µ,À,Á,Â,Ã,Ä,Å,Æ,Ç,È,É,Ê,Ë,Ì,Í,Î,Ï,Ð,Ñ,Ò,Ó,Ô,Õ,Ö,Ø,Ù,Ú,Û,Ü,Ý,ß,à,á,â,ã,ä,å,æ,ç,è,é,ê,ë,ì,í,î,ï,ð,ñ,ò,ó,ô,õ,ö,ø,ù,ú,û,ü,ý,ÿ,-,/,_,',(,)"); $replace = explode(",","S,O,Z,s,o,z,Y,Y,u,A,A,A,A,A,A,A,C,E,E,E,E,I,I,I,I,D,N,O,O,O,O,O,O,U,U,U,U,Y,s,a,a,a,a,a,a,a,c,e,e,e,e,i,i,i,i,o,n,o,o,o,o,o,o,u,u,u,u,y,y, , , , ,,"); $urlTitle = str_replace($search, $replace, $title); Is there a way to make it work with autoit WITHOUT using a new line for each character: $urlTitle = StringReplace($title, "Š", "S") $urlTitle = StringReplace($urlTitle, "Œ", "O") $urlTitle = StringReplace($urlTitle, "Ž", "Z") ... Many thanks for your help Loris Link to comment Share on other sites More sharing options...
GEOSoft Posted May 28, 2010 Share Posted May 28, 2010 I have a hunch without seeing your explode function that you have taken the wrong approach right from the start. All of those values should be in a 2 dimension array or 2 single dimension arrays and then you just use a For/Next loop to check them Here is an example using 2 single dimension arrays. Local $aSearch = StringSplit("Š,Œ,Ž,š,œ,ž,Ÿ,¥,µ,À,Á,Â,Ã,Ä,Å,Æ,Ç,È,É,Ê,Ë,Ì,Í,Î,Ï,Ð,Ñ,Ò,Ó,Ô,Õ,Ö,Ø,Ù,Ú,Û,Ü,Ý,ß,à,á,â,ã,ä,å,æ,ç,è,é,ê,ë,ì,í,î,ï,ð,ñ,ò,ó,ô,õ,ö,ø,ù,ú,û,ü,ý,ÿ", ",", 2) Local $aReplace = StringSplit("S,O,Z,s,o,z,Y,Y,u,A,A,A,A,A,A,A,C,E,E,E,E,I,I,I,I,D,N,O,O,O,O,O,O,U,U,U,U,Y,s,a,a,a,a,a,a,a,c,e,e,e,e,i,i,i,i,o,n,o,o,o,o,o,o,u,u,u,u,y,y", ",", 2) $sStr = "Œ,Ž,š,œ,ž,Ÿ,¥" For $i = 0 To Ubound($aSearch) -1 $sStr = StringReplace($sStr, $aSearch[$i], $aReplace[$i]) Next 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 More sharing options...
symadis Posted May 28, 2010 Author Share Posted May 28, 2010 I have a hunch without seeing your explode function that you have taken the wrong approach right from the start. All of those values should be in a 2 dimension array or 2 single dimension arrays and then you just use a For/Next loop to check them Here is an example using 2 single dimension arrays. Local $aSearch = StringSplit("Š,Œ,Ž,š,œ,ž,Ÿ,¥,µ,À,Á,Â,Ã,Ä,Å,Æ,Ç,È,É,Ê,Ë,Ì,Í,Î,Ï,Ð,Ñ,Ò,Ó,Ô,Õ,Ö,Ø,Ù,Ú,Û,Ü,Ý,ß,à,á,â,ã,ä,å,æ,ç,è,é,ê,ë,ì,í,î,ï,ð,ñ,ò,ó,ô,õ,ö,ø,ù,ú,û,ü,ý,ÿ", ",", 2) Local $aReplace = StringSplit("S,O,Z,s,o,z,Y,Y,u,A,A,A,A,A,A,A,C,E,E,E,E,I,I,I,I,D,N,O,O,O,O,O,O,U,U,U,U,Y,s,a,a,a,a,a,a,a,c,e,e,e,e,i,i,i,i,o,n,o,o,o,o,o,o,u,u,u,u,y,y", ",", 2) $sStr = "Œ,Ž,š,œ,ž,Ÿ,¥" For $i = 0 To Ubound($aSearch) -1 $sStr = StringReplace($sStr, $aSearch[$i], $aReplace[$i]) Next Thanks so much! It's working like this, I knew there was an easy way ! Loris Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now