arcticpup Posted March 17, 2009 Posted March 17, 2009 Hi, Having given myself a headache trying to work this one out, looking at stringsplit and searching the forums etc..... What I want to do is read a reg value as a variable (so far so good) This key will usually(but not always) contain a backslash (it is refering to a servername and sql instance so would normally by server\instance) but obviously server and instance name may change in name and length. what I want to do is read this as a variable and strip out everything after the backslash (including the backslash itself) Any help would be appreciated Thanks
Josbe Posted March 17, 2009 Posted March 17, 2009 Hi, Having given myself a headache trying to work this one out, looking at stringsplit and searching the forums etc..... What I want to do is read a reg value as a variable (so far so good)This key will usually(but not always) contain a backslash (it is refering to a servername and sql instance so would normally by server\instance) but obviously server and instance name may change in name and length. what I want to do is read this as a variable and strip out everything after the backslash (including the backslash itself)Any help would be appreciatedThanksDo you have some code already? (To start) AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
Authenticity Posted March 17, 2009 Posted March 17, 2009 $sServ = StringRegExp($sValue, '(.*)\\', 1) If IsArray($sServ) Then ; Success Else ; Failure EndIf If it may not contain a backslash then you may want to change '\\' to '\\?'.
Szhlopp Posted March 17, 2009 Posted March 17, 2009 (edited) Hi, Having given myself a headache trying to work this one out, looking at stringsplit and searching the forums etc..... What I want to do is read a reg value as a variable (so far so good)This key will usually(but not always) contain a backslash (it is refering to a servername and sql instance so would normally by server\instance) but obviously server and instance name may change in name and length. what I want to do is read this as a variable and strip out everything after the backslash (including the backslash itself)Any help would be appreciatedThanksRegexReplace!Pattern:CODE\\.*Replace:CODEShould look like:CODE$ServerName = StringRegExpReplace($Text, "\\.*", "", 0)Also there is an SRE tester in my sig thatw ill help you a lot for learning how to do these=) Edited March 17, 2009 by Szhlopp RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+'
Drew Posted March 17, 2009 Posted March 17, 2009 (edited) Edit: DAMN you'll are fast O_O. They went more in depth than I did . Edited March 17, 2009 by Drew
arcticpup Posted March 17, 2009 Author Posted March 17, 2009 RegexReplace!Pattern:CODE\\.*Replace:CODEShould look like:CODE$ServerName = StringRegExpReplace($Text, "\\.*", "", 0)Also there is an SRE tester in my sig thatw ill help you a lot for learning how to do these=)Fantastic! Such a simple solution. Many thanks for all your advice!
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