如何更改此代码 [英] How do I change this code

查看:84
本文介绍了如何更改此代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个论坛中的一位绅士给了我这个代码,它非常适合测试

,字符串只包含数字,长度为8个字符。


(!/ ^ \d {8} $ / .test(ContactNo))


如果我希望字符串为任何长度但如何修改上述内容br />
只包含数字?


谢谢

A gentleman in this forum gave me this code and it work great to test
that a string consist of only digits and it is 8 character long.

(!/^\d{8}$/.test(ContactNo) )

How do I modify the above if I want the string to be of any length but
consist of only digits?

Thanks

推荐答案

/.test(ContactNo))

如果我希望字符串为任何长度但是

只包含数字,我如何修改上述内容?


谢谢

/.test(ContactNo) )

How do I modify the above if I want the string to be of any length but
consist of only digits?

Thanks


< ef ***** @ epitome.com.sg>写了
<ef*****@epitome.com.sg> wrote
这个论坛中的一位绅士给了我这个代码,它非常适合测试一个字符串只包含数字并且长度为8个字符。

(!/ ^ \d {8}
A gentleman in this forum gave me this code and it work great to test
that a string consist of only digits and it is 8 character long.

(!/^\d{8}


/ .test(ContactNo))

如果我想要字符串是什么我如何修改上面的任何长度,但
只包含数字?
/.test(ContactNo) )

How do I modify the above if I want the string to be of any length but
consist of only digits?




更改三个字符{8}变成{1,}或者单个+或+。标志。


或除以2,看看它是否仍然是一个数字......


或...

-

Ivo



Change the three characters "{8}" into "{1,}" or into a single "+" sign.

Or divide by 2 and see if it ''s still a number...

Or...
--
Ivo


这篇关于如何更改此代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆