Jump to content

regex troubles


cdr
 Share

Recommended Posts

If I run in autoit:

$test = "Test passed on";
$matchArray = StringRegExp( $test, "(?i)(pass([a-z]?)+[. \-]+[a-z0-9]+)", 1 )

It matches the "e".

However, if I put the pattern in something else that uses regex, like Regex Doctor, the pattern matches "passed on" fine.

What's up?

Edited by cdr
Link to comment
Share on other sites

I don't see what's wrong.

#include <array.au3>
$test = "Test passed on";
$matchArray = StringRegExp( $test, "(?i)(pass([a-z]?)+[. \-]+[a-z0-9]+)", 1 )
_ArrayDisplay($matchArray,"result")
Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Not sure what you mean, but it returns [ e, d, passed on ] when I want it to return just [ passed on ].

I don't see what's wrong.

#include <array.au3>
$test = "Test passed on";
$matchArray = StringRegExp( $test, "(?i)(pass([a-z]?)+[. \-]+[a-z0-9]+)", 1 )
_ArrayDisplay($matchArray,"result")
Edited by cdr
Link to comment
Share on other sites

I guess the problem is the ([a-z]?)+, since it's a subgroup and returns its own matches.

I don't know how else to do it though, {0,} doesn't work for some reason and I don't know why.

I could do something like "(?i)(pass[a-z]{0,10}[. \-]+[a-z0-9]+)", but I prefer a general solution.

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