![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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 .split more than once on a string Can't I do this? Trying to do $a.split('/').split('.'). Tried using extra parenthesis with no luck... 127> $a http://powergadgets.com/csPg/forums/thread/218.aspx [Feed:\powershell\powergadgets] 128> $a.split('/') http: powergadgets.com csPg forums thread 218.aspx [Feed:\powershell\powergadgets] 129> $a.split('/').split('.') Method invocation failed because [System.String[]] doesn't contain a method named 'split'. At line:1 char:20 + $a.split('/').split( <<<< '.') [Feed:\powershell\powergadgets] 130> $a.split('/')|gm TypeName: System.String Name MemberType Definition ---- ---------- ---------- [snip] Split Method System.String[] Split(Params Char[] separator), System.String[] Split(Char[] ... |
| | #2 (permalink) |
| Guest | Re: Using .split more than once on a string Pass both split characters into the Split() call, Marco, like this: $a.Split('/.') Cheers, Matt "Marco Shaw" <marcoDOTshaw_@_gmailDOTcom> wrote in message news:O8Gdb6#SHHA.4872@TK2MSFTNGP03.phx.gbl... > Can't I do this? > > Trying to do $a.split('/').split('.'). > > Tried using extra parenthesis with no luck... > > 127> $a > http://powergadgets.com/csPg/forums/thread/218.aspx > [Feed:\powershell\powergadgets] > 128> $a.split('/') > http: > > powergadgets.com > csPg > forums > thread > 218.aspx > [Feed:\powershell\powergadgets] > 129> $a.split('/').split('.') > Method invocation failed because [System.String[]] doesn't contain a > method named 'split'. > At line:1 char:20 > + $a.split('/').split( <<<< '.') > [Feed:\powershell\powergadgets] > 130> $a.split('/')|gm > > > TypeName: System.String > > Name MemberType Definition > ---- ---------- ---------- > [snip] > Split Method System.String[] Split(Params Char[] > separator), System.String[] Split(Char[] ... > |
| | #3 (permalink) |
| Guest | Re: Using .split more than once on a string Are you trying to do this? ($a.split("/")[2]).split(".") When you split you get an array. You have to decide with of the array elements you want to split again. This may do what you want... what is it you are wanting? $a.split("/") | %{if($_ -match "\."){$_.Split('.')}} -- Brandon Shell --------------- Stop by my blog some time ![]() http://www.bsonposh.com/ Try the "Search of Powershell Blogs" -------------------------------------- "Marco Shaw" <marcoDOTshaw_@_gmailDOTcom> wrote in message news:O8Gdb6%23SHHA.4872@TK2MSFTNGP03.phx.gbl... > Can't I do this? > > Trying to do $a.split('/').split('.'). > > Tried using extra parenthesis with no luck... > > 127> $a > http://powergadgets.com/csPg/forums/thread/218.aspx > [Feed:\powershell\powergadgets] > 128> $a.split('/') > http: > > powergadgets.com > csPg > forums > thread > 218.aspx > [Feed:\powershell\powergadgets] > 129> $a.split('/').split('.') > Method invocation failed because [System.String[]] doesn't contain a > method named 'split'. > At line:1 char:20 > + $a.split('/').split( <<<< '.') > [Feed:\powershell\powergadgets] > 130> $a.split('/')|gm > > > TypeName: System.String > > Name MemberType Definition > ---- ---------- ---------- > [snip] > Split Method System.String[] Split(Params Char[] > separator), System.String[] Split(Char[] ... > |
| | #4 (permalink) |
| Guest | Re: Using .split more than once on a string Wow... thats spiffy... much easier than my way... Man I love Powershell. -- Brandon Shell --------------- Stop by my blog some time ![]() http://www.bsonposh.com/ Try the "Search of Powershell Blogs" -------------------------------------- "mabster" <mabster@madprops.org> wrote in message news:128F9FC7-64CD-4E03-AF2C-BB2568738834@microsoft.com... > Pass both split characters into the Split() call, Marco, like this: > > $a.Split('/.') > > Cheers, > Matt > > "Marco Shaw" <marcoDOTshaw_@_gmailDOTcom> wrote in message > news:O8Gdb6#SHHA.4872@TK2MSFTNGP03.phx.gbl... >> Can't I do this? >> >> Trying to do $a.split('/').split('.'). >> >> Tried using extra parenthesis with no luck... >> >> 127> $a >> http://powergadgets.com/csPg/forums/thread/218.aspx >> [Feed:\powershell\powergadgets] >> 128> $a.split('/') >> http: >> >> powergadgets.com >> csPg >> forums >> thread >> 218.aspx >> [Feed:\powershell\powergadgets] >> 129> $a.split('/').split('.') >> Method invocation failed because [System.String[]] doesn't contain a >> method named 'split'. >> At line:1 char:20 >> + $a.split('/').split( <<<< '.') >> [Feed:\powershell\powergadgets] >> 130> $a.split('/')|gm >> >> >> TypeName: System.String >> >> Name MemberType Definition >> ---- ---------- ---------- >> [snip] >> Split Method System.String[] Split(Params >> Char[] separator), System.String[] Split(Char[] ... >> |
| | #5 (permalink) |
| Guest | Re: Using .split more than once on a string I give psh mad props. To be fair, however, we need to give the .Net framework credit for that one (and all the other methods and properties). ![]() -- William Stacey [C# MVP] PCR concurrency library: www.codeplex.com/pcr PSH Scripts Project www.codeplex.com/psobject "Brandon Shell" <tshell@mask.gmail.com> wrote in message news:uSaHki$SHHA.2256@TK2MSFTNGP02.phx.gbl... | Wow... thats spiffy... much easier than my way... Man I love Powershell. | | -- | Brandon Shell | --------------- | Stop by my blog some time ![]() | http://www.bsonposh.com/ | Try the "Search of Powershell Blogs" | -------------------------------------- | "mabster" <mabster@madprops.org> wrote in message | news:128F9FC7-64CD-4E03-AF2C-BB2568738834@microsoft.com... | > Pass both split characters into the Split() call, Marco, like this: | > | > $a.Split('/.') | > | > Cheers, | > Matt | > | > "Marco Shaw" <marcoDOTshaw_@_gmailDOTcom> wrote in message | > news:O8Gdb6#SHHA.4872@TK2MSFTNGP03.phx.gbl... | >> Can't I do this? | >> | >> Trying to do $a.split('/').split('.'). | >> | >> Tried using extra parenthesis with no luck... | >> | >> 127> $a | >> http://powergadgets.com/csPg/forums/thread/218.aspx | >> [Feed:\powershell\powergadgets] | >> 128> $a.split('/') | >> http: | >> | >> powergadgets.com | >> csPg | >> forums | >> thread | >> 218.aspx | >> [Feed:\powershell\powergadgets] | >> 129> $a.split('/').split('.') | >> Method invocation failed because [System.String[]] doesn't contain a | >> method named 'split'. | >> At line:1 char:20 | >> + $a.split('/').split( <<<< '.') | >> [Feed:\powershell\powergadgets] | >> 130> $a.split('/')|gm | >> | >> | >> TypeName: System.String | >> | >> Name MemberType Definition | >> ---- ---------- ---------- | >> [snip] | >> Split Method System.String[] Split(Params | >> Char[] separator), System.String[] Split(Char[] ... | >> | |
| | #6 (permalink) |
| Guest | Re: Using .split more than once on a string I should have clarified my point.. I meant because there is so many ways to do the same thing and there always seems to be an easier way ![]() -- Brandon Shell --------------- Stop by my blog some time ![]() http://www.bsonposh.com/ Try the "Search of Powershell Blogs" -------------------------------------- "William Stacey [C# MVP]" <william.stacey@gmail.com> wrote in message news:u9bjA$$SHHA.5016@TK2MSFTNGP05.phx.gbl... >I give psh mad props. To be fair, however, we need to give the .Net > framework credit for that one (and all the other methods and properties). > ![]() > > -- > William Stacey [C# MVP] > PCR concurrency library: www.codeplex.com/pcr > PSH Scripts Project www.codeplex.com/psobject > > > "Brandon Shell" <tshell@mask.gmail.com> wrote in message > news:uSaHki$SHHA.2256@TK2MSFTNGP02.phx.gbl... > | Wow... thats spiffy... much easier than my way... Man I love Powershell. > | > | -- > | Brandon Shell > | --------------- > | Stop by my blog some time ![]() > | http://www.bsonposh.com/ > | Try the "Search of Powershell Blogs" > | -------------------------------------- > | "mabster" <mabster@madprops.org> wrote in message > | news:128F9FC7-64CD-4E03-AF2C-BB2568738834@microsoft.com... > | > Pass both split characters into the Split() call, Marco, like this: > | > > | > $a.Split('/.') > | > > | > Cheers, > | > Matt > | > > | > "Marco Shaw" <marcoDOTshaw_@_gmailDOTcom> wrote in message > | > news:O8Gdb6#SHHA.4872@TK2MSFTNGP03.phx.gbl... > | >> Can't I do this? > | >> > | >> Trying to do $a.split('/').split('.'). > | >> > | >> Tried using extra parenthesis with no luck... > | >> > | >> 127> $a > | >> http://powergadgets.com/csPg/forums/thread/218.aspx > | >> [Feed:\powershell\powergadgets] > | >> 128> $a.split('/') > | >> http: > | >> > | >> powergadgets.com > | >> csPg > | >> forums > | >> thread > | >> 218.aspx > | >> [Feed:\powershell\powergadgets] > | >> 129> $a.split('/').split('.') > | >> Method invocation failed because [System.String[]] doesn't contain a > | >> method named 'split'. > | >> At line:1 char:20 > | >> + $a.split('/').split( <<<< '.') > | >> [Feed:\powershell\powergadgets] > | >> 130> $a.split('/')|gm > | >> > | >> > | >> TypeName: System.String > | >> > | >> Name MemberType Definition > | >> ---- ---------- ---------- > | >> [snip] > | >> Split Method System.String[] Split(Params > | >> Char[] separator), System.String[] Split(Char[] ... > | >> > | > > |
| | #7 (permalink) |
| Guest | Re: Using .split more than once on a string Agreed. I just wanted to give the fx props for Split(). Cheers. :-) -- William Stacey [C# MVP] PCR concurrency library: www.codeplex.com/pcr PSH Scripts Project www.codeplex.com/psobject "Brandon Shell" <tshell@mask.gmail.com> wrote in message news:O7rDKbATHHA.3592@TK2MSFTNGP03.phx.gbl... |I should have clarified my point.. I meant because there is so many ways to | do the same thing and there always seems to be an easier way ![]() | | -- | Brandon Shell | --------------- | Stop by my blog some time ![]() | http://www.bsonposh.com/ | Try the "Search of Powershell Blogs" | -------------------------------------- | "William Stacey [C# MVP]" <william.stacey@gmail.com> wrote in message | news:u9bjA$$SHHA.5016@TK2MSFTNGP05.phx.gbl... | >I give psh mad props. To be fair, however, we need to give the .Net | > framework credit for that one (and all the other methods and properties). | > ![]() | > | > -- | > William Stacey [C# MVP] | > PCR concurrency library: www.codeplex.com/pcr | > PSH Scripts Project www.codeplex.com/psobject | > | > | > "Brandon Shell" <tshell@mask.gmail.com> wrote in message | > news:uSaHki$SHHA.2256@TK2MSFTNGP02.phx.gbl... | > | Wow... thats spiffy... much easier than my way... Man I love Powershell. | > | | > | -- | > | Brandon Shell | > | --------------- | > | Stop by my blog some time ![]() | > | http://www.bsonposh.com/ | > | Try the "Search of Powershell Blogs" | > | -------------------------------------- | > | "mabster" <mabster@madprops.org> wrote in message | > | news:128F9FC7-64CD-4E03-AF2C-BB2568738834@microsoft.com... | > | > Pass both split characters into the Split() call, Marco, like this: | > | > | > | > $a.Split('/.') | > | > | > | > Cheers, | > | > Matt | > | > | > | > "Marco Shaw" <marcoDOTshaw_@_gmailDOTcom> wrote in message | > | > news:O8Gdb6#SHHA.4872@TK2MSFTNGP03.phx.gbl... | > | >> Can't I do this? | > | >> | > | >> Trying to do $a.split('/').split('.'). | > | >> | > | >> Tried using extra parenthesis with no luck... | > | >> | > | >> 127> $a | > | >> http://powergadgets.com/csPg/forums/thread/218.aspx | > | >> [Feed:\powershell\powergadgets] | > | >> 128> $a.split('/') | > | >> http: | > | >> | > | >> powergadgets.com | > | >> csPg | > | >> forums | > | >> thread | > | >> 218.aspx | > | >> [Feed:\powershell\powergadgets] | > | >> 129> $a.split('/').split('.') | > | >> Method invocation failed because [System.String[]] doesn't contain a | > | >> method named 'split'. | > | >> At line:1 char:20 | > | >> + $a.split('/').split( <<<< '.') | > | >> [Feed:\powershell\powergadgets] | > | >> 130> $a.split('/')|gm | > | >> | > | >> | > | >> TypeName: System.String | > | >> | > | >> Name MemberType Definition | > | >> ---- ---------- ---------- | > | >> [snip] | > | >> Split Method System.String[] Split(Params | > | >> Char[] separator), System.String[] Split(Char[] ... | > | >> | > | | > | > | |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Find a string within a variable string | Edward.A.Gonzalez | PowerShell | 4 | 2 Weeks Ago 08:13 AM |
| problems with $var | select-string -pattern $string -q | Ben Christian | PowerShell | 3 | 02-08-2008 12:41 PM |
| select-string and .split | alicain | PowerShell | 3 | 10-12-2007 11:01 AM |
| How export-csv deals with string versus string[] | Marco Shaw | PowerShell | 2 | 07-13-2007 12:18 PM |
| String PRODUCT_NAME was not found in string table | Extracampine | Vista General | 3 | 02-12-2007 06:15 AM |