Vossen Posted August 7, 2010 Share Posted August 7, 2010 Hi, I need some help as I never really got StringRegExp. I get text like e.g. ["I WANT THIS","I WANT THIS","I WANT THIS",I WANT THIS]I WANT THIS or ["I WANT THIS","I WANT THIS","I WANT THIS",I WANT THIS]I WANT THIS["I WANT THIS","I WANT THIS","I WANT THIS",I WANT THIS]I WANT THIS["I WANT THIS","I WANT THIS","I WANT THIS",I WANT THIS]I WANT THIS When doing this... StringRegExp($aFile[$i], '(?i)["(.*?)","(.*?)","(.*?)",(.*?)](.*?)', 1) It returns: I WANT THIS","I WANT THIS","I WANT THIS",I WANT THIS]I WANT THIS Then I tried... StringRegExp($aFile[$i], '(?i)["([^"]+)","([^"]+)","([^"]+)",([^"]+)](.*?)', 1) But then it returns nothing... Please help, my brain fried. Did I completely misunderstand the concept of RegExp? // Vossen Link to comment Share on other sites More sharing options...
Bowmore Posted August 7, 2010 Share Posted August 7, 2010 (edited) This should will work for your sample data.#include <array.au3> $Test = '["I WANT THIS","I WANT THIS","I WANT THIS",I WANT THIS]I WANT THIS["I WANT THIS","I WANT THIS","I WANT THIS",I WANT THIS]I WANT THIS["I WANT THIS","I WANT THIS","I WANT THIS",I WANT THIS]I WANT THIS' $aMatches = StringRegExp($Test,["\][,]+([^"\][,]+)',3) _ArrayDisplay($aMatches)Edit: Minor modification to regular expression Edited August 7, 2010 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Vossen Posted August 7, 2010 Author Share Posted August 7, 2010 (edited) It seems to work for my use, thank you! I am not sure I ever will get RegExp. Edit: The new one seems to miss a part though. Edited August 7, 2010 by Vossen Link to comment Share on other sites More sharing options...
seandisanti Posted August 7, 2010 Share Posted August 7, 2010 It seems to work for my use, thank you! I am not sure I ever will get RegExp. Edit: The new one seems to miss a part though. i still struggle with them sometimes, at the bottom of the string regular expression tutorial in the help file there is a tool that has helped me A LOT. StringRegExpGUI.au3 there's a button to load it into scite and then run, and it will let you test patterns etc against sample data etc. The tutorial is a pretty good one for the basics too Link to comment Share on other sites More sharing options...
GEOSoft Posted August 7, 2010 Share Posted August 7, 2010 If you look in my signature there is a PCRE toolkit that will test your regular expressions against data from several sources. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Vossen Posted August 8, 2010 Author Share Posted August 8, 2010 Couldn't make Bowmore's try act 100% as I wanted it to, but thanks to GEOSoft I was able to test all sorts of lame ideas and somehow I made it work. Thanks. 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