User Tools

Site Tools


Sidebar



regexp

Regular Expressions

javascript math id= parameter in querystring

snippet.javascript
var link = "http://aap.com?nav_id=3-1&id=138622&index=14";
var matches = link.match(/&id=([^&]*)/);
var id = matches ? matches[1] : null;
//result: 138622

regexp pal

javascript parse whitespace

snippet.javascript
let wc = "        7      1312";
wc.split(/,?\s+/).filter(Boolean);

Shiffman about regex

Find all URLs starting with http and ending with .html

this works in the SublimeText search function:

(http).*(.html)

Online tools

expr

expr "ok T:83.4 /0.0 B:0.0 /0.0 @:0" : 'ok T:\([0-9]*\.[0-9]*\)'

sed & cut

grep -o '\(T:\)\([0-9]*\.[0-9]*\)' /tmp/UltiFi/ttyACM0/ temp.out | cut -c 3-
grep "spotify:track:" spotify.json | cut -c 16-51
grep "spotify:track:" spotify.json | head -n 1 | cut -c 16-51    # only first result

awk

see awk

turing machine with SED

regexp.txt · Last modified: 2017/06/22 22:15 by rick