regex - Detect quoted strings in sql query -


i writing bash script using detect classes of strings in sql query (like upper-case, lowercase, numeric characters, etc...). before doing classification, want extract quoted strings. having trouble getting regex extract quoted strings query string. example, take query tpch benchmark:

select o_year, sum(case     when nation = 'japan' volume     else 0 end) / sum(volume) mkt_share (     select         extract(year o_orderdate) o_year,         l_extendedprice * (1 - l_discount) volume,         n2.n_name nation             part,         supplier,         lineitem,         orders,         customer,         nation n1,         nation n2,         region             p_partkey = l_partkey         , s_suppkey = l_suppkey         , l_orderkey = o_orderkey         , o_custkey = c_custkey         , c_nationkey = n1.n_nationkey         , n1.n_regionkey = r_regionkey         , r_name = 'asia'         , s_nationkey = n2.n_nationkey         , o_orderdate between date '1995-01-01' , date '1996-12-31'         , p_type = 'medium brushed brass' ) all_nations group o_year order o_year; 

its complex query, besides point. need able extract of single-quoted strings file , print them on own line. ie:

'japan' 'asia' '1995-01-01' '1996-12-31' 'medium brushed brass' 

right now, (being i'm not familiar regex) have is:

printf '%s\n' $sql_file_variable | grep -e "'*'" 

but doesn't support strings spaces, , doesn't work when multiple strings on same line of file. ideally, can work in bash script, preferably solution grep/sed/perl. have done googling , have found solutions similar problems, have not been able them work in particular.

any ideas how can achieve this? thanks.

you want this:

printf '%s\n' $sql_file_variable | grep -e "'[^']*'" 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -