Most everybody on this list probably understands the power of regexp's for
string processing.  Has anybody ever given thought to creating a vector
regexp (I would call it 'subsetting') for codifying complex slices?

Here's what I've come up with so far:

Basic Metacharacters
====================
^   Match the beginning of a vector
$   Match the end of a vector
|   Alternation
()  Grouping
.   Match a single number

Numerical Ranges
================
(a,b)  match any number c such that a <  c <  b
(a,b]  match any number c such that a <  c <= b
[a,b)  match any number c such that a <= c <  b
[a,b]  match any number c such that a <= c <= b

Quantifiers
===========
*      Match 0 or more times
+      Match 1 or more times
?      Match 1 or 0 times
{n}    Match exactly n times
{n,}   Match at least n times
{n,m}  Match at least n but not more than m times

Slicing
=======
s()  Include this group in the resulting slice.

Metacharacters
==============
p     matches a positive number
P     matches a positive number or zero
n     matches a negative number
N     matches a negative number or zero
o     matches zero
O     matches nonzero
M     matches a local maximum
N     matches any character that is not a local maximum
m     mathces a local minimum
n     matches any character that is not a local minimum
M{n}  matches a local maximum near index n
m{n}  mathces a local minimum near index n
\M    matches the global maximum
\m    matches the global minimum

Zero-width Assertions
=====================
\c    Match a zero crossing
\c+   Match a positively sloped zero crossing
\c-   Match a negatively sloped zero crossing
\c=a  Match when the time-series crosses the value a
\c=a+ Match when the time-series crosses the value a with positive slope
\c=a+ Match when the time-series crosses the value a with negative slope
\dN   Match where the Nth numerical derivative crosses zero (also for +- and
=)
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to