regex - Powershell - Retrieve Count from SQLPlus query -


i'm working powershell script utilizes sqlplus query oracle database.

the query is: select count(*) table

the powershell query outputs:

sql*plus: release 11.2.0.1.0 production on sat feb 6 09:50:52 2016  copyright (c) 1982, 2010, oracle.  rights reserved.   connected to: oracle database 11g enterprise edition release 11.2.0.3.0 - 64bit production partitioning, real application clusters, automatic storage management, olap, data mining , real application testing options     count(*) ----------     50  disconnected oracle database 11g enterprise edition release 11.2.0.3.0 - 64bit production partitioning, real application clusters, automatic storage management, olap, data mining , real application testing options 

i'm using statement below retrieve count, though seems not capturing result.

if($file -match 'count (?<count>\d+)'){$count=[int32]$matches['count']} 

any help/guidance appreciated. thanks!

i see 1 problem , potential issue. latter being suspect $file string array. works against since looking number based on presence of text couple lines above.

the problem regex not multi-line , in sample number not appear on same line count. regex match count 50. not how appear in text show.

two ensure both points lets make $file 1 single string , run multi-line regex matches first number encountered after "count". keep named match logic have nice have.

# can moved read in. $file = $file | out-string  # try , match regex.  if($file -match "(?s)count.*?(?<count>\d+)"){     [int32]$matches.count } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -