Imp Posted February 14, 2018 Share Posted February 14, 2018 Hello! Please help me help with regular expressions. For example, i need to parse AutoIt function declaration and extract function and parameters names. In sample below StringRegExp() returns function name and last parameter. It is possible get all parameters with one call? #include <Array.au3> Global $sTest = " Func NNN ( $XXX, $yyy ) " Global $sPattern = "^\s*(?:(?i)func)\s+(\w+)(?:[^\$]*(\$\w+))*" Global $aResult = StringRegExp( $sTest, $sPattern, 1 ) _ArrayDisplay( $aResult ) Link to comment Share on other sites More sharing options...
SlackerAl Posted February 14, 2018 Share Posted February 14, 2018 (edited) How about: (?:^|\s)(\$\w+) any word beginning with space $ And get the function name first... (?<=Func\s)(\w+)|(?:^|\s)(\$\w+) Edited February 14, 2018 by SlackerAl Added function name Problem solving step 1: Write a simple, self-contained, running, replicator of your problem. Link to comment Share on other sites More sharing options...
mikell Posted February 14, 2018 Share Posted February 14, 2018 ? #include <Array.au3> Global $sTest = " Func _NNN ( $XXX, $yyy ) ; some comments about $yyy here " Global $sPattern = "(?i)(?|func|;.*$)(*SKIP)(?!)|(\$?\w+)" Global $aResult = StringRegExp( $sTest, $sPattern, 3 ) _ArrayDisplay( $aResult ) Link to comment Share on other sites More sharing options...
Imp Posted February 14, 2018 Author Share Posted February 14, 2018 Thank you very much! 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