Qualitybit Posted July 9, 2007 Share Posted July 9, 2007 (edited) I have a string containing a long text. Within the text are scattered informations within several pairs of parantheses '()'. So I need only this one pair of parantheses, which NOT contains numbers or a '*'. In short: I want the parantheses only containing letters and NOT the other parantheses containing letters, numbers or a '*'. RegExp starts to hate me at the very early beginning, where I try at a first step to extract the whole pairs of parantheses... EDIT - example: 1. design #1365 (72$) (*) 2. design #2437 (59$) (in stock) 3. design #3424 (29$) (*)(* means not available at the moment) for in ... IF stringregexp ($row[$i], "magic regexp proof if "()" with only letters in it exist", 0) THEN $avail[$ii] = $row[$i] next 101011 Edited July 9, 2007 by Qualitybit [font="Courier New"][center]Me vs. 127.0.0.1 =>> 0:2But I never give up! >:-][/center][/font] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 9, 2007 Moderators Share Posted July 9, 2007 (edited) I have a string containing a long text. Within the text are scattered informations within several pairs of parantheses '()'. So I need only this one pair of parantheses, which NOT contains numbers or a '*'. In short: I want the parantheses only containing letters and NOT the other parantheses containing letters, numbers or a '*'. RegExp starts to hate me at the very early beginning, where I try at a first step to extract the whole pairs of parantheses... 101011 An example string, the code you've attempted, and the output you desire (written) would make more sense then what you have. Edit: This is how I'm understanding your question:#include <array.au3> $sString = '(((abcd)))' $aArray = StringRegExp($sString, '(?s)(?i)\(+(.*?)\)', 3) _ArrayDisplay($aArray) Edited July 9, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
/dev/null Posted July 9, 2007 Share Posted July 9, 2007 (edited) An example string, the code you've attempted, and the output you desire (written) would make more sense then what you have. Edit: This is how I'm understanding your question:#include <array.au3> $sString = '(((abcd)))' $aArray = StringRegExp($sString, '(?s)(?i)\(+(.*?)\)', 3) _ArrayDisplay($aArray) I suggest this one ;-)) #include <array.au3> $text = "Hi, I don't know how to (post) a proper (problem) description, thus (345) people have to guess what I'm talking about (f***)" $regexp = "(\([^\*\d]*?\))" $result = StringRegExp($text,$regexp,3) _ArrayDisplay($result) Cheers Kurt Edited July 9, 2007 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 9, 2007 Moderators Share Posted July 9, 2007 (edited) I suggest this one ;-)) #include <array.au3> $text = "Hi, I don't know how to (post) a proper (problem) description, thus (345) people have to guess what I'm talking about (f***)" $regexp = "(\([^\*\d]*?\))" $result = StringRegExp($text,$regexp,3) _ArrayDisplay($result) Cheers KurtWouldn't it just be:$regexp = '(?s)\(\w+\)'? Edit: NVM, didn't notice that the area could have a "space" , I only read he wanted the areas with only regular characters. Edited July 9, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Qualitybit Posted July 9, 2007 Author Share Posted July 9, 2007 Wouldn't it just be:$regexp = '(?s)\(\w+\)'? Problem solved! THX to all contriputors! 101011 ...a few years aged [font="Courier New"][center]Me vs. 127.0.0.1 =>> 0:2But I never give up! >:-][/center][/font] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 9, 2007 Moderators Share Posted July 9, 2007 Problem solved! THX to all contriputors! 101011 ...a few years agedI think this is more what you want if you want spaces as well.$regexp = '(?s)\((\w+\s*)+\)' Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
/dev/null Posted July 9, 2007 Share Posted July 9, 2007 Wouldn't it just be:$regexp = '(?s)\(\w+\)'? Edit: NVM, didn't notice that the area could have a "space" , I only read he wanted the areas with only regular characters. what happens if the text contains some special characters, like !,;./: etc? Like this: "N/A" __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 9, 2007 Moderators Share Posted July 9, 2007 what happens if the text contains some special characters, like !,;./: etc? Like this: "N/A"SOL? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
/dev/null Posted July 9, 2007 Share Posted July 9, 2007 SOL? SOL? __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 9, 2007 Share Posted July 9, 2007 Hi, \([^\*\$0-9]*\) 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...
Moderators SmOke_N Posted July 9, 2007 Moderators Share Posted July 9, 2007 (edited) SOL?http://www.urbandictionary.com/define.php?term=sol Edit: Hi, \([^\*\$0-9]*\) So long, Mega That looks right mega... I'd do the (?s) though... $regexp = '(?s)\([^\*\$\d]*\)' Edited July 9, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 9, 2007 Share Posted July 9, 2007 http://www.urbandictionary.com/define.php?term=sol Edit: That looks right mega... I'd do the (?s) though... $regexp = '(?s)\([^\*\$\d]*\)' HI, matching newline. Maybe it can be useful. So what ... 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...
/dev/null Posted July 9, 2007 Share Posted July 9, 2007 http://www.urbandictionary.com/define.php?term=solnice ... __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * 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