FaridAgl Posted February 10, 2013 Share Posted February 10, 2013 (edited) Well, I have no clue on StringRegExp(), would be nice if someone give some little helps. The code explains itself: Global Const $TEXT_A = "SpeCtR3._.n1 - SpamBot" ;Needs SpeCtR3._.n1 Global Const $TEXT_B = "D4RK-ON3 - Server 2" ;Needs D4RK-ON3 Global Const $TEXT_C = "EXuCHER - WhisperBot" ;Needs EXuCHER Global Const $TEXT_D = "Whatever here A - Whatever here B" ;Needs Whatever here A As commented in the code, the output of StringRegExp() should be everything before the last dash (-), note that there could be more than one dash ($TEXT_. Thanks in advance. Edited February 10, 2013 by D4RKON3 http://faridaghili.ir Link to comment Share on other sites More sharing options...
Bert Posted February 10, 2013 Share Posted February 10, 2013 In the helpfile there is a script that is actually a StringRegEx tool. Look in the Tutorial section > String Regular Expression. At the bottom of the page is the button to open the script in SciTE. Run it and the tool will make it much easier to figure out what you have in mind. Also, read the tutorial. It helps! FaridAgl 1 The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
FaridAgl Posted February 10, 2013 Author Share Posted February 10, 2013 I did it this way, and works, tips are welcomed. $iDelimiter = StringInStr($TEXT_D, " - ") $sOutput = StringLeft($TEXT_D, $iDelimiter) MsgBox(0, '', $sOutput) http://faridaghili.ir Link to comment Share on other sites More sharing options...
Bert Posted February 10, 2013 Share Posted February 10, 2013 did you even look at the tool? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
FaridAgl Posted February 10, 2013 Author Share Posted February 10, 2013 In the helpfile there is a script that is actually a StringRegEx tool. Look in the Tutorial section > String Regular Expression. At the bottom of the page is the button to open the script in SciTE. Run it and the tool will make it much easier to figure out what you have in mind. Also, read the tutorial. It helps!Thank you, I found that. http://faridaghili.ir Link to comment Share on other sites More sharing options...
FaridAgl Posted February 10, 2013 Author Share Posted February 10, 2013 did you even look at the tool?I saw your post after I post, I'm looking on it now. http://faridaghili.ir Link to comment Share on other sites More sharing options...
FaridAgl Posted February 10, 2013 Author Share Posted February 10, 2013 The tool doesn't help so much as I'm don't know much (anything) about Regular Expression, would be nice if some expert do me this favor. The first post is still available! http://faridaghili.ir Link to comment Share on other sites More sharing options...
Kyan Posted February 10, 2013 Share Posted February 10, 2013 (edited) this will do the job StringRegExp($TEXT_A,"(.*?)\-(?:.*?)\z",3) for multiline, you need to replace z with r or n EDIT: () --> Capturing group .*? --> Matchs every character (.), 0 or more times (*), fewer possible (?) - --> Dash escaped (to escape a char. use back slash) (?: ... ) --> Non capturing group (just for reference) z --> Marks string end so if you read it, capture every characters behind a dash, and do not capture the existing chars between a dash and string end Edited February 10, 2013 by DiOgO Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
FaridAgl Posted February 10, 2013 Author Share Posted February 10, 2013 Thank you my friend. For $TEXT_B it returns "D4RK" instead of "D4RK-ON3". For the others, it has a whitespace " " at the end. http://faridaghili.ir Link to comment Share on other sites More sharing options...
Kyan Posted February 10, 2013 Share Posted February 10, 2013 Thank you my friend. For $TEXT_B it returns "D4RK" instead of "D4RK-ON3". For the others, it has a whitespace " " at the end. just add a space before - or put a dot (match a character) works fine for me: Global Const $TEXT_A = "SpeCtR3._.n1 - SpamBot" ;Needs SpeCtR3._.n1 Global Const $TEXT_B = "D4RK-ON3 - Server 2" ;Needs D4RK-ON3 Global Const $TEXT_C = "EXuCHER - WhisperBot" ;Needs EXuCHER Global Const $TEXT_D = "Whatever here A - Whatever here B" ;Needs Whatever here A $reqa = StringRegExp($TEXT_A, "(.*?) \-(?:.*?)\z", 3) $reqb = StringRegExp($TEXT_B, "(.*?) \-(?:.*?)\z", 3) $reqc = StringRegExp($TEXT_C, "(.*?) \-(?:.*?)\z", 3) $reqd = StringRegExp($TEXT_D, "(.*?) \-(?:.*?)\z", 3) MsgBox(0, "", $reqa[0] & @CRLF & $reqb[0] & @CRLF & $reqc[0] & @CRLF & $reqd[0]) Exit Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
FaridAgl Posted February 10, 2013 Author Share Posted February 10, 2013 Yeap, that rocks now. Thank you. http://faridaghili.ir Link to comment Share on other sites More sharing options...
Kyan Posted February 10, 2013 Share Posted February 10, 2013 you're welcomeDiOgO Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better 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