Jump to content

StringRegExp


Recommended Posts

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? :blink:

// Vossen

Link to comment
Share on other sites

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 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

It seems to work for my use, thank you! I am not sure I ever will get RegExp. :blink:

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...