Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - regex help

Reply
 
Old 07-02-2008   #1 (permalink)
tonyr


 
 

regex help

in a hurry and my minds not working, need to be able to parse something like
the following

aksdjf[need.this]akdjkjdkfj

basically I need the stuff between the square brackets so the result would be

need.this

thanks in advance



My System SpecsSystem Spec
Old 07-02-2008   #2 (permalink)
Kiron


 
 

Re: regex help

$str = 'aksdjf[need.this]akdjkjdkfj'
$str -replace '.*\[(.*)].*','$1'

--
Kiron
My System SpecsSystem Spec
Old 07-02-2008   #3 (permalink)
tonyr


 
 

Re: regex help

love ya man!
tr

"Kiron" wrote:
Quote:

> $str = 'aksdjf[need.this]akdjkjdkfj'
> $str -replace '.*\[(.*)].*','$1'
>
> --
> Kiron
>
My System SpecsSystem Spec
Old 07-02-2008   #4 (permalink)
Kirk Munro [MVP]


 
 

Re: regex help

Something like:

if ($myString -match '\[(.+)\]') {
$internalValue = $matches[1]
}

--
Kirk Munro [MVP]
Poshoholic
http://poshoholic.com


"tonyr" <tonyr@xxxxxx> a écrit dans le message de groupe
de discussion : C4F49F6A-7B18-49F6-AA31-2B2BA5346B58@xxxxxx...
Quote:

> in a hurry and my minds not working, need to be able to parse something
> like
> the following
>
> aksdjf[need.this]akdjkjdkfj
>
> basically I need the stuff between the square brackets so the result would
> be
>
> need.this
>
> thanks in advance
>
>
My System SpecsSystem Spec
Old 07-02-2008   #5 (permalink)
Kirk Munro [MVP]


 
 

Re: regex help

Sorry, disregard that, refresh is slow today and I thought you were still
waiting on an answer.

"Kirk Munro [MVP]" <see.my.about.page.on@xxxxxx> a écrit
dans le message de groupe de discussion :
B14FA603-79E3-476B-88EC-B75A0AD9A2B0@xxxxxx...
Quote:

> Something like:
>
> if ($myString -match '\[(.+)\]') {
> $internalValue = $matches[1]
> }
>
> --
> Kirk Munro [MVP]
> Poshoholic
> http://poshoholic.com
>
>
> "tonyr" <tonyr@xxxxxx> a écrit dans le message de
> groupe de discussion :
> C4F49F6A-7B18-49F6-AA31-2B2BA5346B58@xxxxxx...
Quote:

>> in a hurry and my minds not working, need to be able to parse something
>> like
>> the following
>>
>> aksdjf[need.this]akdjkjdkfj
>>
>> basically I need the stuff between the square brackets so the result
>> would be
>>
>> need.this
>>
>> thanks in advance
>>
>>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Regex help please? PowerShell
regex help PowerShell
Regex Help PowerShell
Regex Help .NET General
regex PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46