Jump to content

[Solved]StringRegExp


Xand3r
 Share

Recommended Posts

$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

Link to comment
Share on other sites

$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))
;===============================================================
Link to comment
Share on other sites

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

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