RegEx

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
8 posts • Page 1 of 1
SudoBen
Posts:11
Joined: Fri Apr 08, 2011 9:25 am

RegEx

Post by SudoBen »

Hello again,
i have run into another Problem:
I'm triing to filter DP Names that are hold in a dyn_string via dynPatternMatch.

The Names are always build up llike device__property_propertyOfProperty_....
I am trying to filter all properties of the first level that do NOT have child properties.

I supposed the Regex to be something like
"*Device_??_/[[:alpha:]/]+"
"*Device_??_[:alpha:]+"
"*Device_??[/a]+"
"*Device_??[a-zA-Z]+"

"*Device_??[/a]*"

But none of this works :(

So I have serious problems to figure out the right RegExp.
Folowing the help i looked up the regex syntax for unix commands (http://www.mkssoftware.com/docs/man5/re ... gexp.5.asp e.g.) .

Is there any more specific documentation how regular expressions are implemented in WOA?
(Or a RegEx that suits my Problem ;) )

Thanks in advance

Best regards

BK

mpoint
Posts:49
Joined: Thu Oct 28, 2010 11:28 am

Re: RegEx

Post by mpoint »

I don't think dynPatternMatch() supports Regex. It's more like fnmatch() or "globbing".

EDIT:
It's probably easy to miss, but the online help says:
The asterisk "*" replaces any number of characters, the question mark "?" replaces any character, characters in square brackets one of the characters specified in brackets.
That's basically globbing.

SudoBen
Posts:11
Joined: Fri Apr 08, 2011 9:25 am

Re: RegEx

Post by SudoBen »

Your'e right it behaves like gobbing,
but the help states (dynPatternMatch):
Under Linux, the same rules for pattern apply as those that apply in Linux command lines for addressing files: These rules can be retrieved with "man 5 regexp" on Linux computers.
What I need to find is a pattern that matches e.g. 3 digits and 4 chars.

Is that possible to archive with WOA? Or are * and ? the only supported wild cards (no character classes and complements available)?

SudoBen
Posts:11
Joined: Fri Apr 08, 2011 9:25 am

Re: RegEx

Post by SudoBen »

Ok, i found a (not very elegant) way:
[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][1234567890][1234567890][1234567890][1234567890][1234567890]

:woohoo: :woohoo: :woohoo:

But maybe someone comes up with a better solution :unsure:

mpoint
Posts:49
Joined: Thu Oct 28, 2010 11:28 am

Re: RegEx

Post by mpoint »

I'm pretty sure you can shorten it by using ranges, like "[a-zA-Z]" and "[0-9]".

SudoBen
Posts:11
Joined: Fri Apr 08, 2011 9:25 am

Re: RegEx

Post by SudoBen »

Nope. Unfortunately not. :dry:

Code: Select all

patternMatch("[a-z][a-z]","aa") //No Match
Like quantifiers

Code: Select all

patternMatch("[a]{2}","aa") //No Match
It looks like only very basic expressions are recognized :unsure:

That would be hell of a nice enhancement in one of the upcoming Versions :laugh:

mpoint
Posts:49
Joined: Thu Oct 28, 2010 11:28 am

Re: RegEx

Post by mpoint »

Here's an alternative: Since Ctrl is extensible, you can help yourself out regarding regex support.

I put together this little experimental Ctrl Extension last evening: https://github.com/mooware/CtrlRegex. It provides replacements for patternMatch() and dynPatternMatch() based on the QRegExp class from Qt. And the bonus is, it even supports real globbing if you specify the pattern type "wildcard".

SudoBen
Posts:11
Joined: Fri Apr 08, 2011 9:25 am

Re: RegEx

Post by SudoBen »

Cool , nice one :)

Looking forward to give it a closer look.

8 posts • Page 1 of 1