我有一个随机生成的实例URL,它包含不同的6位数代码,具体取决于它所呈现的环境。我一直在尝试实现这个指南的一个版本。然而,在我没有使用regexp之前,我发现实现这个更令人困惑,捕获这样一个URL的最好和最安全的方法是什么?
的例子:
123675.apps.testwebsite.com
我已经试过了:
^[0-9]{1,6}.--apps.testwebsite.com z
如何使用:
allow do
origins "localhost:3000", "127.0.0.1:3000",
/Ahttp://192.168.0.d{1,3}(:d+)?z/
# Here needs to be a Regexp that validates the entire URL.
end
编辑:
my_string = '123679.apps.testwebsite.com'
string_check = my_string.match(/^[0-9]{6}.apps.testwebsite.com/)
=> #<MatchData "123679.apps.testwebsite.com">
"123675.apps.testwebsite.com".match?(/^[0-9]{6}.apps.testwebsite.com/)
=> true
只有在.apps.testwebsite.com