Jump to content

String headache


Recommended Posts

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

Link to comment
Share on other sites

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)
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
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...