water Posted February 26, 2010 Share Posted February 26, 2010 Hi RegExp gurus, I have a script that lets the user filter the displayed records by entering the pattern for StringRegExp. If he enters "KSE" he gets all records containing this string. What should the user enter if he wants all records but "KSE"? Thanks in advance My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
dani Posted February 26, 2010 Share Posted February 26, 2010 (edited) ".*(?!KSE).*" Edited February 26, 2010 by d4ni Link to comment Share on other sites More sharing options...
water Posted February 26, 2010 Author Share Posted February 26, 2010 ".*(?!KSE).*" Thanks for your reply. Your example returns TRUE when the pattern isn't found in the string but unfortunately it returns TRUE as well when the pattern is found in the string. I need a pattern for StringRegExp that only returns true when the pattern can not be found in the string ConsoleWrite(StringRegExp("AB_IK_Leitung",".*(?!KSE).*") & @CRLF) ConsoleWrite(StringRegExp("TM_IK_KSE_Leitung",".*(?!KSE).*") & @CRLF) Both return TRUE but only example 1 should. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
dani Posted February 26, 2010 Share Posted February 26, 2010 (edited) Hm strange I will look into it. I have recently looked this up myself and I thought it was that notation. I'll find the solution !Here you go:$regEx = "\A(?!.*KSE).*\z" ConsoleWrite(StringRegExp("AB_IK_Leitung", $regEx) & @CRLF) ConsoleWrite(StringRegExp("TM_IK_KSE_Leitung", $regEx) & @CRLF)Apparently one of the wildcards was supposed to go inside the (?!) group, and \A and \z were needed. In my script I added the \A and \z automatically to the user's RegEx, like:Func Input($regEx) StringRegExp($str, "(?i)\A" & $regEx & "\z") ; (?i) for case insensitive ... EndFuncAnyway, the exclude isn't very userfriendly You might want to say it's "!KSE" and then form the actual Regular Expression yourself.If you want to do that you can use this:$r = "!KSE" ; This would be what is entered in the inputbox $regEx = StringRegExpReplace($r, "!(.*)", "(?!.*\1).*") ; This replacement also works if the user enters !(KSE|IK) -- exclude strings which include "KSE" OR "IK" ConsoleWrite(StringRegExp("AB_IK_Leitung", "\A" & $regEx & "\z") & @CRLF) ConsoleWrite(StringRegExp("TM_IK_KSE_Leitung", "\A" & $regEx & "\z") & @CRLF) Edited February 26, 2010 by d4ni Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now