![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Using $ signs in strings Hi, I recently tried to put a $ sign into a string for a variable but it kept coming back as cutting off everything after the $ though it thought the string was the combination of a string and another variable. If i have a string which contains a $ sign, how do i write it to allow it to be recognized as just part of the string, and not a seperate variable. Here is how i am doing it now. This is the only way i could find to get it to work. $Variable = "12345abc" + "$" + "12345abc" There has to be an easier way than that. |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: Using $ signs in strings greatbarrier86 wrote:
PS> $variable="123`$abc" PS> $variable 123$abc -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Using $ signs in strings Yep! that worked. Can you explain what you mean by "escape the $." I got the meaning, but why "escape"? "Marco Shaw [MVP]" wrote:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Using $ signs in strings Thanks to both of you. Shay, i like your suggestion but what bothers me is that to someone else just starting out, it may seem strange that one of the strings in single while the rest are in double. Personally, it wouldnt bother me either way. What do you think? "Shay Levi" wrote:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest | Re: Using $ signs in strings greatbarrier86 wrote:
Interpret the following character differently... | ||||||||||||
My System Specs![]() | |||||||||||||
| | #6 (permalink) | ||||||||||||
| Guest | Re: Using $ signs in strings Another option is to wrap the string in single quotes: PS > $Variable = '12345$abc' PS > $Variable 12345$abc --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #7 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Using $ signs in strings Thanks! "Marco Shaw [MVP]" wrote:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #8 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Using $ signs in strings So you suggest not using the escape char? "Shay Levi" wrote:
| ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
| | #9 (permalink) | ||||||||||||
| Guest | Re: Using $ signs in strings greatbarrier86 wrote:
PSH>"abc`$123" abc$123 PSH>$foo="@#" PSH>"abc`$123$foo" abc$123@# PSH>'abc`$123$foo' abc`$123$foo <--Definitely not the same outcome PSH> | ||||||||||||
My System Specs![]() | |||||||||||||
| | #10 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Using $ signs in strings It may confuse at first but it has a good reason, type this in your console to get the explanation: PS > help about_quoting_rules --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| WLM signs me out when I try and send a message...PLEASE HELP!! | klee82 | Live Messenger | 1 | 1 Week Ago 05:33 PM |
| + signs next to in box messages | Steve | Vista mail | 1 | 08-21-2008 07:57 AM |
| Plus signs in file names | granovet | Live Folder Share | 0 | 07-21-2008 05:32 PM |
| FS Signs in all libraries are greyed out | johnc | Live Folder Share | 1 | 06-16-2008 07:47 PM |
| Know about the signs on DVD discs | Jazz2008 | Vista General | 2 | 05-21-2008 08:18 AM |