The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

mod2008 (6) [Avatar] Offline
#1
Hello All,

I tried the regular expression example on page 111/112 (Parsing command output using regular expressions - using the "net config" tool) which works, however I cannot get the following to work using a similar method:

I have a string which contains "(width=320, Height=30)" and want to extract only the numbers from it using -match. I then want to be able to refer to these matches by using the named entries within the $matches hash table for example:

$matches.width
320

$matches.height
30

How can I achieve this?

Thanks for your help and I hope I have not confused anyone,

Ivan.
franck (17) [Avatar] Offline
#2
Re: Rglr Expression problem driving me nuts
Hi Ivan

The following works.

============================================================
'widths*=s*(?<width>[^,]+).*heights*=s*(?<height>[^)]+)'
============================================================

With 's*' (four time) it works also with blancs between the name (height or width) and the sign '='.

'width=320' or 'width =320' or 'width= 320' or 'width = 320' are all OK.

Regards Franck
mod2008 (6) [Avatar] Offline
#3
Re: Rglr Expression problem driving me nuts
Hi Franck,

A very big Thank You - it works a treat.

I need to study up more on Regular Expressions; I am still a little dizzy with it! smilie

Regards,

Ivan.