Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

regex help

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-02-2008   #1 (permalink)
tonyr
Guest


 

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
Guest


 

Re: regex help

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

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


 

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]
Guest


 

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]
Guest


 

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
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex IT Staff PowerShell 3 08-29-2008 07:33 AM
Regex Help dm_14 PowerShell 7 06-11-2008 08:33 PM
Regex Help Christopher Robin .NET General 1 03-31-2008 02:02 PM
regex IT Staff PowerShell 4 01-02-2008 02:07 AM
Regex question Marco Shaw PowerShell 9 03-02-2007 11:01 AM


Vistax64.com 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 2005-2008

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 47 48 49 50 51