Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
var num = 1 var pattern = /hai/+num+/world/
它打印:
> "/hai/1/world/"
虽然我希望它打印这个:
> /hai1world/
任何线索?
var num = 1; var pattern = new RegExp('hai' + num + 'world');
您不能/.../与变量一起使用。
/.../