Jump to content
Sign in to follow this  
Okke

_StringBetween in combination with a regular expression

Recommended Posts

Okke

Hi,

I need some help with grabbing a piece of text using _StringBetween in combination with a regular expression.

CODE
#include <String.au3>

#include <array.au3>

$sString = "speler[0] = new Speler('83451', 'L.T.C. Vleuten de Meern', 'Vleuten', '10852530', 'A. Smaal', 'M', '21-01-1944', '7', '8', '2009', 'http://test.url' 'UTR', 'Senior');"

$aNamen = _StringBetween($sString, "new Speler('(.*?)', '(.*?)', '(.*?)', '(.*?)', '", "', '[MV]'", -1, 1)

If @error Or Not IsArray($aNamen) Then

MsgBox(16,"Error", "Failed!")

Else

_ArrayDisplay($aNamen)

EndIf

;StringRegExp($sString, '(?s)' & $vCase & $sStart & '(.*?)' & $sEnd, 3) => String.au3 code segment

Anybody an idea what I am doing wrong?

TIA, Okke

Share this post


Link to post
Share on other sites
andybiochem

Hi,

I need some help with grabbing a piece of text using _StringBetween in combination with a regular expression.

TIA, Okke

What data are you trying to grab?

is this any good:

#include <String.au3>
#include <array.au3>

$sString = "speler[0] = new Speler('83451', 'L.T.C. Vleuten de Meern', 'Vleuten', '10852530', 'A. Smaal', 'M', '21-01-1944', '7', '8', '2009', 'http://test.url', 'UTR', 'Senior');"
$aNamen = _StringBetween($sString, "(.*', '){4}","', '[MV]'", -1, 1)
If Not IsArray($aNamen) Then
MsgBox(16,"Error", "Failed!")
Else
_ArrayDisplay($aNamen)
EndIf

;StringRegExp($sString, '(?s)' & $vCase & $sStart & '(.*?)' & $sEnd, 3) => String.au3 code segment

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites
Okke

What data are you trying to grab?

I would like to get an array with in this particular case the string "A. Smaal" as the first element.

In your solution it almost worked out, although an extra substring matched.

Tried fiddling with the expression but I didn't come up with the solution yet.

Any ideas?

Share this post


Link to post
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
Sign in to follow this  

×