Luigi Posted February 22, 2019 Share Posted February 22, 2019 Greetings, Someone can help-me with regex? #include <StringConstants.au3> Global $STRUCT1 = "Struct;char host[128];char sudo[128];char user[128];char pass[128];char path[256];char cmd[128];int code;EndStruct" Global $regex = "[^,;]+" ;~ $regex = "^[.*?;|;.*:]" Global $aStruct = StringRegExp($STRUCT1, $regex, $STR_REGEXPARRAYGLOBALMATCH) _ArrayDisplay( $aStruct ) I want extract an array with: char,host,128 char,sudo,128 char,user,128 char,pass,128 char,path,256 char,cmd,128 int,code, Best regards. Visit my repository Link to comment Share on other sites More sharing options...
user4157124 Posted February 22, 2019 Share Posted February 22, 2019 (edited) Possibly: ;([^ ]+) ([^[;]+)\[*([0-9]*)?\]* Edited February 22, 2019 by user4157124 Quantifiers Luigi 1 AUERLO (AutoIt error logger) Link to comment Share on other sites More sharing options...
Luigi Posted February 22, 2019 Author Share Posted February 22, 2019 @user4157124, perfect! Thank you! Visit my repository Link to comment Share on other sites More sharing options...
iamtheky Posted March 2, 2019 Share Posted March 2, 2019 also non-regex fun and 2D arrays #include<array.au3> local $a[0][3] Global $STRUCT1 = "Struct;char host[128];char sudo[128];char user[128];char pass[128];char path[256];char cmd[128];int code;EndStruct" _ArrayAdd($a , StringReplace(StringReplace(StringReplace(StringReplace(StringReplace($STRUCT1 , ";EndStruct" , "" , 1) , "Struct;" , "" , 1) , "]" , "") , " " , ",") , "[" , ",") , 0 , "," , ";") _ArrayDisplay($a) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
mikell Posted March 2, 2019 Share Posted March 2, 2019 (edited) #include<array.au3> local $a[0][3] Global $STRUCT1 = "Struct;char host[128];char sudo[128];char user[128];char pass[128];char path[256];char cmd[128];int code;EndStruct" _ArrayAdd($a , StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($STRUCT1, ';?(End)?Struct;?', ""), '\]?;', @crlf) , '[ \[]', "|") ) _ArrayDisplay($a) Edit The new smileys are *awful* Edited March 2, 2019 by mikell iamtheky 1 Link to comment Share on other sites More sharing options...
iamtheky Posted March 2, 2019 Share Posted March 2, 2019 let the skinning begin! #include<array.au3> Global $STRUCT1 = "Struct;char host[128];char sudo[128];char user[128];char pass[128];char path[256];char cmd[128];int code;EndStruct" _ArrayDisplay(stringsplit(_ArrayToString(StringSplit(stringtrimright($STRUCT1 , 10) , ";[] " , 2) , "," , 1) , ",," , 3)) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
iamtheky Posted March 3, 2019 Share Posted March 3, 2019 half the ops, but the result has a bonus linefeed at the beginning... Global $STRUCT1 = "Struct;char host[128];char sudo[128];char user[128];char pass[128];char path[256];char cmd[128];int code;EndStruct" MsgBox(0, '' , StringRegExpReplace(StringRegExpReplace($STRUCT1 , "[\[\] ]" , ",") , "(Struct;|,;|;EndStruct)" , @LF)) Fr33b0w 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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