regex - Get suffix from Expressjs routing -
i have requests followings:
/name-of-anything-1/another-name-2/and-a-third-name-3
i want able suffix in param (-1
, -2
, -3
in cases). had next route doesn't work:
app.get('/:optional-:suffix?*', function(req, res) { //anything
}
i obtain first '-'
, need lastly 1 , rest @ 'optional' param.
thx in advance.
you can split whole string @ hyphen -
, lastly 1 out
app.get('/:optional', function(req, res){ var suffix = req.params[optional].split('-').reverse()[0]; }
regex node.js express
No comments:
Post a Comment