![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Vista Ultimate x32 | Text manipulation question I did a script that outputs a remote client's network connected printers (according to their dmain SID via registry) to a text file. The text output is in the format eg: HKEY_USERS\S-1-5-21-xxxxxxxxxx-3770063950-2320700579-61605\Printers\Connections\,,ServerName,QueueName I'd like to mainpulate that output to: \\ServerName\QueueName Any tips on how to do this? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Text manipulation question On Aug 25, 8:17*pm, aukiman <gu...@xxxxxx-email.com> wrote: Quote: > I did a script that outputs a remote client's network connected printers > (according to their dmain SID via registry) to a text file. > > The text output is in the format eg: > > HKEY_USERS\S-1-5-21-xxxxxxxxxx-3770063950-2320700579-61605\Printers\Connect ions\,,ServerName,QueueName > > I'd like to mainpulate that output to: > > '\\ServerName\QueueName' (file://\\ServerName\QueueName) > > Any tips on how to do this? > > -- > aukiman > > '[image:http://i85.photobucket.com/albums/k6...onmansig-n...]' > (http://www.radioaukiman.com/forums) [regex]$pattern = ',,([^,]+),([^,]+)$' $server = $groups[1].Value $queue = $groups[2].Value echo "\\$server\$queue (file://\\$server\$queue)" I don't know how familiar you are with regular expressions, but basically that's ,, -- two commas ( -- start grouping [^,]+ -- one or more characters that are NOT commas ) -- finish grouping etc... |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Text manipulation question $str -replace '.+,,(.+),(.+)','\\$1\$2 (file://\\$1\$2)' -- Kiron |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Text manipulation question On Aug 25, 10:37*pm, tojo2000 <tojo2...@xxxxxx> wrote: Quote: > On Aug 25, 8:17*pm, aukiman <gu...@xxxxxx-email.com> wrote: > > > Quote: > > I did a script that outputs a remote client's network connected printers > > (according to their dmain SID via registry) to a text file. Quote: > > The text output is in the format eg: Quote: > > HKEY_USERS\S-1-5-21-xxxxxxxxxx-3770063950-2320700579-61605\Printers\Connect ions\,,ServerName,QueueName Quote: > > I'd like to mainpulate that output to: Quote: > > '\\ServerName\QueueName' (file://\\ServerName\QueueName) Quote: > > Any tips on how to do this? Quote: > > -- > > aukiman Quote: > Here's one way to do it: > > [regex]$pattern = ',,([^,]+),([^,]+)$' > $server = $groups[1].Value > $queue = $groups[2].Value > echo "\\$server\$queue (file://\\$server\$queue)" > > I don't know how familiar you are with regular expressions, but > basically that's > > ,, * * *-- two commas > ( * * * -- start grouping > [^,]+ *-- one or more characters that are NOT commas > ) * * * -- finish grouping > > etc... PS C:\> $path = 'HKEY_USERS\S-1-5-21- xxxxxxxxxx-3770063950-2320700579-61605\Printers\Connect ions \,,ServerName,QueueName' PS C:\> [regex]$pattern = ',,([^,]+),([^,]+)$' PS C:\> $groups = $pattern.Match($path).Groups PS C:\> $server = $groups[1].Value PS C:\> $queue = $groups[2].Value PS C:\> echo "\\$server\$queue (file://\\$server\$queue)" \\ServerName\QueueName (file://\\ServerName\QueueName) |
My System Specs![]() |
| | #5 (permalink) |
| Vista Ultimate x32 | Re: Text manipulation question brilliant ! thanks for the help guys, first time I've used expressions. Definitely not the last |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Text file manipulation | PowerShell | |||
| Re: Question concerning copying from the text body | Live Mail | |||
| Re: Question concerning copying from the text body | Live Mail | |||
| Windows programming and image manipulation in Powershell question | PowerShell | |||