Jump to content
Sign in to follow this  
Xand3r

[Solved]StringRegExp

Recommended Posts

Xand3r

$data1="test test test test "
$data2="test"
$pattern=".{4,}"$reg1=StringRegExp($data1,$pattern)
$reg2=StringRegExp($data2,$pattern)
MsgBox(0  , "SRE" , $reg1 & ":" & $reg2)

I want it to match repeating sequences only 4 or more times :)

what should i change the $pattern to so the msgbox shows "1 : 0" ?

Edited by Xand3r

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites
Malkey

$data1="test test test test "
$data2="test"
$pattern=".{4,}"$reg1=StringRegExp($data1,$pattern)
$reg2=StringRegExp($data2,$pattern)
MsgBox(0 , "SRE" , $reg1 & ":" & $reg2)

I want it to match repeating sequences only 4 or more times :D

what should i change the $pattern to so the msgbox shows "1 : 0" ?

Maybe something like this.

#include <Array.au3>

$data1 = "test test test test " ;test test test test test test test test test test test test "
$data2 = "test"
$pattern = "(\w+\h*)(?:\1){3,}"
$reg1 = StringRegExp($data1, $pattern)
$reg2 = StringRegExp($data2, $pattern)

MsgBox(0, "SRE", $reg1 & ":" & $reg2)


;======= This section to help show what's happening only =======
$pattern = "(\w+\h*)(?:\1){3,}" ; ";
$reg1 = StringRegExp($data1, $pattern, 3)
$reg2 = StringRegExp($data2, $pattern, 3)

_ArrayDisplay($reg1)
MsgBox(0, "Display", UBound($reg1) & ":" & UBound($reg2))
;===============================================================

Share this post


Link to post
Share on other sites
Xand3r

Maybe something like this.

#include <Array.au3>

$data1 = "test test test test " ;test test test test test test test test test test test test "
$data2 = "test"
$pattern = "(\w+\h*)(?:\1){3,}"
$reg1 = StringRegExp($data1, $pattern)
$reg2 = StringRegExp($data2, $pattern)

MsgBox(0, "SRE", $reg1 & ":" & $reg2)


;======= This section to help show what's happening only =======
$pattern = "(\w+\h*)(?:\1){3,}" ; ";
$reg1 = StringRegExp($data1, $pattern, 3)
$reg2 = StringRegExp($data2, $pattern, 3)

_ArrayDisplay($reg1)
MsgBox(0, "Display", UBound($reg1) & ":" & UBound($reg2))
;===============================================================

thanks alot Malkey that's exactly what i was looking for :)

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.