Jump to content
Sign in to follow this  
arcticpup

String headache

Recommended Posts

arcticpup

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

Share this post


Link to post
Share on other sites
Josbe

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

Do you have some code already? (To start)

Share this post


Link to post
Share on other sites
Szhlopp

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

RegexReplace!

Pattern:

CODE
\\.*

Replace:

CODE

Should 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 by Szhlopp

Share this post


Link to post
Share on other sites
Drew

Edit: DAMN you'll are fast O_O.

They went more in depth than I did :P.

Edited by Drew

Share this post


Link to post
Share on other sites
arcticpup

RegexReplace!

Pattern:

CODE
\\.*

Replace:

CODE

Should 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! :P

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.