WeMartiansAreFriendly Posted August 5, 2007 Share Posted August 5, 2007 I need to split up a string like this:47.5% (.Word) Description (10527/13/4)into 4 partsso it would be turned it this47.5% .Word Description 10527/13/4Im can't get into how to do this.. regular expressions? well heres my code.Local $sStr, $a[4] Local $sStringf = '47.5% (.Word) Description (10527/13/4)' $sStr = StringStripWS($sStringf,3) $a[0] = StringLeft($sStr, StringInStr($sStr,'(') -1) $a[1] = StringLeft(StringMid($sStr, StringInStr($sStr,'(')),StringInStr($sStr,')')) $a[2] = StringMid($sStr, StringInStr($sStr,'(')) $a[3] = StringRight($sStr, StringInStr($sStr,')',0,1)) MsgBox(0,$sStringf,$a[0] &@lf& $a[1] &@lf& $a[2] &@lf& $a[3]) #cs want to return 47.5% .Word Description 10527/13/4 #ce Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
xcal Posted August 5, 2007 Share Posted August 5, 2007 (edited) Why not just StringSplit at the spaces? edit - And StringReplace, of course, to get rid of the brackets. #include <array.au3> ; just for arraydisplay $str = StringReplace('47.5% (.Word) Description (10527/13/4)', '(', '') $str = StringReplace($str, ')', '') $ret = StringSplit($str, ' ') _ArrayDisplay($ret) Edited August 5, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted August 5, 2007 Author Share Posted August 5, 2007 Why not just StringSplit at the spaces? edit - And StringReplace, of course, to get rid of the brackets. #include <array.au3> ; just for arraydisplay $str = StringReplace('47.5% (.Word) Description (10527/13/4)', '(', '') $str = StringReplace($str, ')', '') $ret = StringSplit($str, ' ') _ArrayDisplay($ret) I knew it was something so simple I was overlooking. big thanks Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted August 5, 2007 Author Share Posted August 5, 2007 Erg.. I ran into a problem, which now I remember why I didn't use stringsplit() If the string contains more than one space in the second part it will output e.g. I forgot about that. 47.5% .Word cWord3 cWord2 cWord3 10527/13/4 47.5% .Word cWord3 cWord2 cWord3 10527/13/4 I need 47.5% .Word cWord3 cWord2 cWord3 10527/13/4 Any other ideas?? Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() 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