-
Notifications
You must be signed in to change notification settings - Fork 1
symbol at
Subhajit Sahu edited this page May 5, 2020
·
1 revision
Get set-listed symbol at specified index in string.
const symbolAt = require('@extra-string/symbol-at');
// symbolAt(<string>, <symbol set>, [index=0], [max symbol length])
symbolAt('rho+pi', new Set().add('pi').add('rho').add('+').add('-'), 0);
// 'rho'
symbolAt('rho+pi', new Set().add('pi').add('rho').add('+').add('-'), 2);
// undefined (no match at 2)
symbolAt('rho+pi', new Set().add('pi').add('rho').add('+').add('-'), 3);
// '+'
symbolAt('rho+pi', new Set(['pi', 'rho', '+', '-']), 4, 3);
// 'pi' (longest symbol='rho')