{"id":2813,"date":"2017-10-03T08:04:25","date_gmt":"2017-10-03T08:04:25","guid":{"rendered":"https:\/\/www.mjtnet.com\/blog\/?p=2813"},"modified":"2017-10-03T08:04:25","modified_gmt":"2017-10-03T08:04:25","slug":"regular-expressions-regex-in-window-commands","status":"publish","type":"post","link":"https:\/\/www.mjtnet.com\/blog\/2017\/10\/03\/regular-expressions-regex-in-window-commands\/","title":{"rendered":"Regular Expressions (RegEx) In Window Commands"},"content":{"rendered":"<p>Did you know you can use Regular Expressions inside any of <a href=\"http:\/\/www.mjtnet.com\/macro-scheduler.htm\">Macro Scheduler<\/a>&#8216;s window functions (e.g. <a href=\"http:\/\/www.mjtnet.com\/manual\/setfocus.htm\">SetFocus<\/a>, <a href=\"http:\/\/www.mjtnet.com\/manual\/waitwindowopen.htm\">WaitWindowOpen<\/a>, <a href=\"http:\/\/www.mjtnet.com\/manual\/waitwindowclosed.htm\">WaitWindowClosed<\/a>) so that you can match a window title using RegEx?<\/p>\n<p>As an example someone recently asked us how they would match a window from an old piece of software where the window title was always the letter &#8220;b&#8221; followed by any 8 digits, e.g. b23425461.  Macro Scheduler uses the <a href=\"http:\/\/pcre.org\/\">PCRE<\/a> syntax, so to match a window title like this we could use this expression:<\/p>\n<blockquote><p>^b\\d{8}<\/p><\/blockquote>\n<p>If you&#8217;re new to RegEx this means: match from the beginning of the string (^), then match a &#8220;b&#8221; character followed by any digit (\\d) 8 times. {8} means match the proceeding token 8 times.  So:<\/p>\n<pre name=\"code\" class=\"macroscript\">Let>WIN_USEREGEX=1\r\nSetFocus>^b\\d{8}<\/pre>\n<p>I&#8217;ve posted a little about Regular Expressions before. <a href=\"https:\/\/www.mjtnet.com\/blog\/2009\/04\/30\/regular-expressions-for-dummies\/\">This post<\/a> links to some useful resources if you are new to RegEx.<\/p>\n<p><a href=\"https:\/\/www.mjtnet.com\/blog\/2009\/04\/30\/regular-expressions-for-dummies\/\">Regular Expressions for Dummies<\/a><br \/>\n<a href=\"https:\/\/www.mjtnet.com\/blog\/2012\/10\/29\/my-most-used-regex\/\">My Most Used RegEx<\/a><br \/>\n<a href=\"https:\/\/www.mjtnet.com\/blog\/2010\/01\/11\/remove-tags-from-html-with-regex\/\">Remove Tags From HTML with RegEx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did you know you can use Regular Expressions inside any of Macro Scheduler&#8216;s window functions (e.g. SetFocus, WaitWindowOpen, WaitWindowClosed) so that you can match a window title using RegEx? As an example someone recently asked us how they would match a window from an old piece of software where the window title was always the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/2813"}],"collection":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/comments?post=2813"}],"version-history":[{"count":4,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/2813\/revisions"}],"predecessor-version":[{"id":2818,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/2813\/revisions\/2818"}],"wp:attachment":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/media?parent=2813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/categories?post=2813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/tags?post=2813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}