How do I insert a variable into a regex .match() assertion?
Asked Answered
C

1

7

I would like to add a variable, 'example', into a regular expression assertion.

const example = Selector('xyz');

await t.expect(getLocation()).match(/^https:\/\/int-.*.example.com\/en\/example\/-\/  ** HERE SHOULD BE INSERTED A VARIABLE, 'example' ** \/$/)

How could I do this?

Calicle answered 14/6, 2019 at 10:43 Comment(0)
F
5

You can make it using the RegExp Constructor.

Finch answered 14/6, 2019 at 15:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.