mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-26 17:28:13 +00:00
This commit is contained in:
parent
ebbdb4f31a
commit
c07a5a71e2
3 changed files with 55 additions and 0 deletions
|
|
@ -154,6 +154,20 @@ POKI_RUN_COMMAND{{echo x,y,z | mlr --csv --implicit-csv-header reorder -f 3,1,2}
|
|||
|
||||
POKI_RUN_COMMAND{{echo 'x.a=3,y:b=4,z/c=5' | mlr put '${product.all} = ${x.a} * ${y:b} * ${z/c}'}}HERE
|
||||
|
||||
</div>
|
||||
<h1>How to escape '?' in regexes?</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_escape_in_regex');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_escape_in_regex" style="display: block">
|
||||
|
||||
<p/> One way is to use square brackets; an alternative is to use simple
|
||||
string-substitution rather than a regular expression.
|
||||
|
||||
POKI_RUN_COMMAND{{cat data/question.dat}}HERE
|
||||
POKI_RUN_COMMAND{{mlr --oxtab put '$c = gsub($a, "[?]"," ...")' data/question.dat}}HERE
|
||||
POKI_RUN_COMMAND{{mlr --oxtab put '$c = ssub($a, "?"," ...")' data/question.dat}}HERE
|
||||
|
||||
<p/> The <tt>ssub</tt> function exists precisely for this reason: so you don’t have to escape anything.
|
||||
|
||||
</div>
|
||||
<h1>How can I put single-quotes into strings?</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_single_quotes_in_strings');" href="javascript:;">Toggle section visibility</button>
|
||||
|
|
|
|||
1
doc/data/question.dat
Normal file
1
doc/data/question.dat
Normal file
|
|
@ -0,0 +1 @@
|
|||
a=is it?,b=it is!
|
||||
40
doc/faq.html
40
doc/faq.html
|
|
@ -195,6 +195,7 @@ Miller commands were run with pretty-print-tabular output format.
|
|||
• <a href="#How_do_I_examine_then-chaining?">How do I examine then-chaining?</a><br/>
|
||||
• <a href="#I_assigned_$9_and_it’s_not_9th">I assigned $9 and it’s not 9th</a><br/>
|
||||
• <a href="#How_can_I_handle_field_names_with_special_symbols_in_them?">How can I handle field names with special symbols in them?</a><br/>
|
||||
• <a href="#How_to_escape_'?'_in_regexes?">How to escape '?' in regexes?</a><br/>
|
||||
• <a href="#How_can_I_put_single-quotes_into_strings?">How can I put single-quotes into strings?</a><br/>
|
||||
• <a href="#Why_doesn’t_mlr_cut_put_fields_in_the_order_I_want?">Why doesn’t mlr cut put fields in the order I want?</a><br/>
|
||||
• <a href="#NR_is_not_consecutive_after_then-chaining">NR is not consecutive after then-chaining</a><br/>
|
||||
|
|
@ -596,6 +597,45 @@ x.a=3,y:b=4,z/c=5,product.all=60
|
|||
</div>
|
||||
<p/>
|
||||
|
||||
</div>
|
||||
<a id="How_to_escape_'?'_in_regexes?"/><h1>How to escape '?' in regexes?</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_escape_in_regex');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_escape_in_regex" style="display: block">
|
||||
|
||||
<p/> One way is to use square brackets; an alternative is to use simple
|
||||
string-substitution rather than a regular expression.
|
||||
|
||||
<p/>
|
||||
<div class="pokipanel">
|
||||
<pre>
|
||||
$ cat data/question.dat
|
||||
a=is it?,b=it is!
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
<p/>
|
||||
<div class="pokipanel">
|
||||
<pre>
|
||||
$ mlr --oxtab put '$c = gsub($a, "[?]"," ...")' data/question.dat
|
||||
a is it?
|
||||
b it is!
|
||||
c is it ...
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
<p/>
|
||||
<div class="pokipanel">
|
||||
<pre>
|
||||
$ mlr --oxtab put '$c = ssub($a, "?"," ...")' data/question.dat
|
||||
a is it?
|
||||
b it is!
|
||||
c is it ...
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
||||
<p/> The <tt>ssub</tt> function exists precisely for this reason: so you don’t have to escape anything.
|
||||
|
||||
</div>
|
||||
<a id="How_can_I_put_single-quotes_into_strings?"/><h1>How can I put single-quotes into strings?</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_single_quotes_in_strings');" href="javascript:;">Toggle section visibility</button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue