Jump to content

Need help with regexp


Jon
 Share

Recommended Posts

  • Administrators

Not being a regexp man I need some help.

What would the StringRegExp expression be to match "blah.txt - Notepad" but wouldn't match "Untitled - Notepad".

(I know it's a trival example, but I'm, erm, experimenting with something...)

Link to comment
Share on other sites

Uhhh... wow. Thats kind of hard. I don't claim to be an expert on regular expressions or anything so I may be missing something obvious, but... wow, thats kind of hard. It seems to me like there should be some way to negate a group. For example, this would match (if it worked): "(^Untitled) - Notepad". That would say "match anything but Untitled". However, thats not implemented and I'm not entirely sure if it should be.

Link to comment
Share on other sites

What about:

"[.]txt - Notepad"

This would match the .txt at the end of the file name. If you want to match any extension how about "[.].*- Notepad"?

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

In classic regexps you'd use something like:

/\w[.]w{2,3} - Notepad/

...to insure that before the " - Notepad" there was a file name of at least one character, a dot and a one-or-two character extension. If it's a concern that the party might have extensions hidden then the only thing I know that you could do is verify that the title isn't "Untitled - Notepad"...

[EDIT] grammatical error

Edited by DaveF

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

  • Administrators

Ok ok. I didn't really want to get into details I just wanted something simple that I could test with.

Opt("WinTitleMatchMode", 4)
WinWaitActive("regexp=[.].*- Notepad")

:lmao:o:)

Link to comment
Share on other sites

@Jon:

I have been thinking about RegExp and window title matching before.

I have read several times that a regular expression search will use more resources than any other function.

I'm wondering if StringRegExp can return within 250ms.

Because if the window is closed during the process strange things would happen (?)

Edit:

I just saw you added that in. I will test it out now.

Edited by SlimShady
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...