JavaScript Regex Extract

March 6, 2020
const m = 'page-1234'.match(/^(page|album)-(\d+)/)
if (m) {
    const name = m[1]
    const number = m[2]
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.