File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -165,4 +165,19 @@ b it is!
165
165
c is it ...
166
166
</pre >
167
167
168
- The ` ssub ` function exists precisely for this reason: so you don't have to escape anything.
168
+ The [ ` ssub ` ] ( reference-dsl-builtin-functions.md#ssub ) function exists precisely for this reason: so you don't have to escape anything.
169
+
170
+ ## How to apply math to regex output?
171
+
172
+ * Use parentheses for capture groups
173
+ * Use ` \1 ` , ` \2 ` , etc. to refer to the captures
174
+ * The matched patterns are strings, so cast them to ` int ` or ` float `
175
+
176
+ See also the [ page on regular expressions] ( reference-main-regular-expressions.md ) .
177
+
178
+ <pre class =" pre-highlight-in-pair " >
179
+ <b >echo "a=14°45'" | mlr put '$a =~"^([0-9]+)°([0-9]+)" {$degrees = float("\1") + float("\2") / 60}'</b >
180
+ </pre >
181
+ <pre class =" pre-non-highlight-in-pair " >
182
+ a=14°45',degrees=14.75
183
+ </pre >
Original file line number Diff line number Diff line change @@ -89,4 +89,16 @@ GENMD-RUN-COMMAND
89
89
mlr --oxtab put '$c = ssub($a, "?"," ...")' data/question.dat
90
90
GENMD-EOF
91
91
92
- The `ssub` function exists precisely for this reason: so you don't have to escape anything.
92
+ The [`ssub`](reference-dsl-builtin-functions.md#ssub) function exists precisely for this reason: so you don't have to escape anything.
93
+
94
+ ## How to apply math to regex output?
95
+
96
+ * Use parentheses for capture groups
97
+ * Use `\1`, `\2`, etc. to refer to the captures
98
+ * The matched patterns are strings, so cast them to `int` or `float`
99
+
100
+ See also the [page on regular expressions](reference-main-regular-expressions.md).
101
+
102
+ GENMD-RUN-COMMAND
103
+ echo "a=14°45'" | mlr put '$a =~"^([0-9]+)°([0-9]+)" {$degrees = float("\1") + float("\2") / 60}'
104
+ GENMD-EOF
Original file line number Diff line number Diff line change @@ -3,12 +3,14 @@ RELEASES
3
3
* plan 6.1.0
4
4
o unsparsify -f CSV by default -- ? into CSV record-writer -- ? caveat that record 1 controls all ...
5
5
o mlr join --left-fields a,b,c
6
- o several needs-doc issues
7
- https://github.com/johnkerl/miller/issues?q=is%3Aissue+is%3Aopen+label%3Aneeds-documentation
8
6
o fmt/unfmt/regex doc
9
7
o FAQ/examples reorg
10
8
? ??? for doc-string contents search -- ? & mlr help namegoeshere foo ...
11
9
10
+ o several needs-doc issues
11
+ https://github.com/johnkerl/miller/issues?q=is%3Aissue+is%3Aopen+label%3Aneeds-documentation
12
+ echo "a=14°20" | mlr put '$out=sub($a,"^([0-9]+)°([0-9]+)$","\1\2")'
13
+
12
14
k strptime/882
13
15
k fmtifnum, & recursive fmtnum/fmtifnum
14
16
k unicode string literals
@@ -26,6 +28,9 @@ RELEASES
26
28
k ?foo and ??foo @ repl help
27
29
k doc-improves
28
30
31
+ d all-contribs check before release
32
+ > release notes in particular Poshi derekmahar aborruso
33
+
29
34
* plan 6.2.0
30
35
! extended field accessors for #763 and #948 (positional & json.nested)
31
36
! strict mode
You can’t perform that action at this time.
0 commit comments