Zedna Posted May 31, 2007 Share Posted May 31, 2007 (edited) I need to extract name and initial values from my string: column=(type=number updatewhereclause=yes name=cpa_kniha dbname="cpa_kniha" initial="getdate()" values="1/0")but sometimes it can be in differrent order (first initial and second name): column=(type=number updatewhereclause=yes initial="getdate()" name=cpa_kniha dbname="cpa_kniha" values="1/0") I have done it by two calls of StringRegExp(): $ret = StringRegExp($line, '(?i)name=(.*?)\x20(.*?)initial="(.*?)"', 3) If @Error = 2 Then $ret = ' !!! CHYBA RegExp !!! pozice: ' & @extended ElseIf @Error = 0 Then $ret = 'name=' & $ret[0] & ' initial=' & $ret[2] ElseIf @Error = 1 Then ; if not found (but is there), so they are in differrent order $ret = StringRegExp($line, '(?i)initial="(.*?)"(.*?)name=(.*?)\x20', 3) If @Error <> 0 Then $ret = ' !!! CHYBA RegExp !!! pozice: ' & @extended Else $ret = 'name=' & $ret[2] & ' initial=' & $ret[0] EndIf EndIf Edited May 31, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 31, 2007 Share Posted May 31, 2007 HI, do you need it sorted or is this enough? #include<Array.au3> $str = 'column=(type=number updatewhereclause=yes name=cpa_kniha dbname="cpa_kniha" initial="getdate()" values="1/0")' & @CRLF & _ 'column=(type=number updatewhereclause=yes initial="getdate()" name=cpa_kniha dbname="cpa_kniha" values="1/0")' $ret = StringRegExp($str, '(?<=name=).*?(?=dbname)|(?<=initial=").*?(?=")', 3) _ArrayDisplay($ret) So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Zedna Posted May 31, 2007 Author Share Posted May 31, 2007 (edited) HI, do you need it sorted or is this enough? #include<Array.au3> $str = 'column=(type=number updatewhereclause=yes name=cpa_kniha dbname="cpa_kniha" initial="getdate()" values="1/0")' & @CRLF & _ 'column=(type=number updatewhereclause=yes initial="getdate()" name=cpa_kniha dbname="cpa_kniha" values="1/0")' $ret = StringRegExp($str, '(?<=name=).*?(?=dbname)|(?<=initial=").*?(?=")', 3) _ArrayDisplay($ret)oÝ÷ Ù*%¢xz¿ªê-y8ZK7Ý8Z·l·´Z½ê')bæò)Þ¦ºzË"(²íx"²z-çyÐn·*.®Ê%ºØ¨+'¢Úh²ÈëhºÇ¢¹mçºÇçën®wrn{"Ø^±©¢·^®èºÚn¶z&jØ^®Ø^º+uêè)éºÔzlÅ©©â7öh¶Ø§v¦y©Ýx©_®¶¸§ kzÛ«çZ®¶²{h+p¢«¨¶ö«¹^²«¨¶Þ~çjgÚ'yú+x©X¢êéjÛ^®x§~*ì¶X§z·º¹Û©ý¶¬~*ì¶ö¥¹æ§u¸§ØöڲǢw^½©nz)ìyÊ'vX§z·º¹Ûx©m«»-½©ny©Ýnv¦{öڲǢw^½©nx-+,¢g¡£ h²Èëh²oy±!?Ûrn{©u¹Úè§Øöè)éºÙbç·¢©ò¢·^»Ê«¥«mz¹ëzX²éë,ºjmí«[u¹ÚïÛƵêÛ©ý´áz·¦ºË[zl¦zØhwOvÇm:Ùø«²Û)iÇ~׫© Edited May 31, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 31, 2007 Share Posted May 31, 2007 Hi, I connot sort it or save into 2 arrays. :-( #include<Array.au3> $str = 'column=(type=number updatewhereclause=yes name=cpa_kniha dbname="cpa_kniha" initial="getdate()" values="1/0")' & @CRLF & _ 'column=(type=number updatewhereclause=yes initial="getdate()" name=cpa_kniha dbname="cpa_kniha" values="1/0")' $ret = StringRegExp($str, '(?<= name=)\S+|(?<=initial=")[\w(\)]+', 3) _ArrayDisplay($ret) So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Zedna Posted May 31, 2007 Author Share Posted May 31, 2007 (edited) This is my testing script: On every StringRegExp only one line Both results should return columns in the same order $str = 'column=(type=number updatewhereclause=yes name=cpa_kniha dbname="cpa_kniha2" initial="getdate()" values="1/0")' $ret = StringRegExp($str, '(?<=name=).*?(?=dbname)|(?<=initial=").*?(?=")', 3) _ArrayDisplay($ret,'') $str = 'column=(type=number updatewhereclause=yes initial="getdate()" name=cpa_kniha dbname="cpa_kniha" values="1/0")' $ret = StringRegExp($str, '(?<=name=).*?(?=dbname)|(?<=initial=").*?(?=")', 3) _ArrayDisplay($ret,'') Edited May 31, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 1, 2007 Share Posted June 1, 2007 Hi, just a little step forwards. #include<Array.au3> $str = 'column=(type=number updatewhereclause=yes name=cpa_kniha dbname="cpa_kniha" initial="getdate()" values="1/0")' & @CRLF & _ 'column=(type=number updatewhereclause=yes initial="getdate()" name=cpa_kniha dbname="cpa_kniha" values="1/0")' $ret = StringRegExp($str, '/(name)=\"*([\w\(\)]+)\"*|(initial)=\"*([\w\(\)]+)\"*', 3) _ArrayDisplay($ret, '') So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Zedna Posted June 1, 2007 Author Share Posted June 1, 2007 (edited) Hi, just a little step forwards. #include<Array.au3> $str = 'column=(type=number updatewhereclause=yes name=cpa_kniha dbname="cpa_kniha" initial="getdate()" values="1/0")' & @CRLF & _ 'column=(type=number updatewhereclause=yes initial="getdate()" name=cpa_kniha dbname="cpa_kniha" values="1/0")' $ret = StringRegExp($str, '/(name)=\"*([\w\(\)]+)\"*|(initial)=\"*([\w\(\)]+)\"*', 3) _ArrayDisplay($ret, '') So long, Mega Thanks very much for assistance th.meger This looks like it could be done. It's close to final but result is bad: I'm reg exp amater, so your patterns are too difficult for me to understand Edited June 1, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search 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