首页 \ 问答 \ PHP的正则表达式来检查一个数字是否由5位数组成(php regular expression to check whether a number consists of 5 digits)

PHP的正则表达式来检查一个数字是否由5位数组成(php regular expression to check whether a number consists of 5 digits)

如何编写正则表达式来检查一个数字是否只包含5位数字?


how to write a regular expression to check whether a number is consisting only of 5 digits?


原文:https://stackoverflow.com/questions/1204844
更新时间:2024-01-21 14:01

最满意答案

两点之间的距离(毕达哥拉):

dx = x1 - x2;
dy = y1 - y2;

dist = sqrt (dx*dx + dy*dy);

两条水平线之间的距离:

d = y1 - y2;

如果你的线被定义为y1 = k1x + n1y2 = k2x + n2 ,那么(它们是水平的, k1k2是0)它们之间的距离是n2 - n1

编辑:好的,在你编辑了你的问题之后,它现在变得更有意义了。 但仍然是:既然你(或用户)正在添加行,你的代码总是知道它们在哪里。 他们的结束坐标是:

line1:{(0,y1):( picture.width,y1)} line2:{(0,y2):( picture.width,y2)} distance:| y2-y1 |

因为它们都是水平的,所以它们永远不会交叉。

您应该在适当的空间中保留对y1和y2(来自放线代码)的引用。 由于您的问题是针对Android和iOS的,因此答案是:在与MVC中的model相对应的那部分代码中。


Distance between two points (Pythagora):

dx = x1 - x2;
dy = y1 - y2;

dist = sqrt (dx*dx + dy*dy);

Distance between two horizontal lines:

d = y1 - y2;

If your lines are defined as y1 = k1x + n1 and y2 = k2x + n2, then (they're horizontal, k1 and k2 are 0) the distance between them is n2 - n1.

EDIT: ok, after you edited your question it makes a bit more sense now. But still: since you (or user) is adding the lines, your code always knows where they lie. Their end coordinates would be:

line1: {(0,y1):(picture.width,y1)} line2: {(0,y2):(picture.width,y2)} distance: |y2-y1|

Since they're both horizontal they ofcourse never cross.

You should just keep a reference to y1 and y2 (from the line-placing code) in an appropriate space. Since your question is for Android and iOS the answer is: in that part of code that would correspond to model in MVC.

相关问答

更多
  • 根据定义,一点是1/72英寸 - 参见Wikipedia Point_(排版) 像素的大小取决于设备上的屏幕分辨率。 需要明确的是,这通常以每英寸点数(dpi)表示。 这不是术语分辨率的常用用法,即屏幕的像素高度和宽度。 人们以这种方式错误地使用分辨率。 分辨率是屏幕上的点密度,而不是屏幕上的像素数。 这里的要点是屏幕上显示的像素数与点所需的像素数之间没有关系。 您无法使用您尝试的转化。 要确定与1点匹配的像素数,您必须获得屏幕的分辨率。 BB提供了两种方法: Display.getHorizontalRe ...
  • 每英寸有72点 ; 如果足以假定每英寸96个像素,则公式相当简单: 点=像素* 72/96 有一种方法可以使用GetDeviceCaps在Windows中获得每英寸显示的配置像素。 Microsoft有一个名为“开发DPI-Aware应用程序”的指南 ,查找“创建DPI感知字体”部分。 W3C将像素测量值定义为1in的1/96,而不管显示器的实际分辨率如何,因此上述公式应该对所有网络工作都有好处。 There are 72 points per inch; if it is sufficient to as ...
  • 搜索词组多边形链简化 ,你会看到有关于这个主题的相当多的文献。 这是一个可以引导您到其他人的参考: Buzer,Lilian。 “用于亚像素精确渲染的多边形链的最佳简化。” Computational Geometry 42.1(2009):45-59。 Search for the phrase polygonal chain simplification and you'll see there is quite a literature on this topic. Here is one refer ...
  • 方法是正确的,但我会使用单应性。 角度是无关紧要的,交叉是射影不变的 不必要。 是的,在估计平面与其图像之间的单应性之后,可以从图像估计平面上的每个距离,只要已知至少一个可以解决比例。 “可接受”是旁观者的眼睛,因为它取决于您的申请。 你的意大利面配方可能有2.67%的相对误差,但如果你是一个想要在桥上连接横梁的焊工,那么任何超过几毫米的东西都会太多。 建议 - 测量更多点,消除非线性失真(图像上部的墙壁底部的线看起来弯曲),估计单应性。 The method is correct, though I wo ...
  • 设ImageDim是x和y坐标中图像的长度。 在这种情况下,它将是ImageDim = (700, 500) ,并让StadionDim成为体育场的长度。 StadionDim = (125, 86)因此,计算体育场中图像中的点的函数将是: def calc(ImageDim, StadionDim, Point): return (Point[0] * StadionDim[0]/ImageDim[0], Point[1] * StadionDim[1]/ImageDim[1]) 所以现在你会在 ...
  • geof:distance函数接受Geometries作为其前两个参数。 因此,使用您的简化查询,使用geof:distance(?geo1, ?geo2, unit:Kilometer)应该可以得到您想要的结果。 Stardog博客有一个地理空间入门文章 ,您可能会觉得有用。 The geof:distance function accepts Geometries as its first two parameters. So with your simplified query, using geof ...
  • 两点之间的距离(毕达哥拉): dx = x1 - x2; dy = y1 - y2; dist = sqrt (dx*dx + dy*dy); 两条水平线之间的距离: d = y1 - y2; 如果你的线被定义为y1 = k1x + n1和y2 = k2x + n2 ,那么(它们是水平的, k1和k2是0)它们之间的距离是n2 - n1 。 编辑:好的,在你编辑了你的问题之后,它现在变得更有意义了。 但仍然是:既然你(或用户)正在添加行,你的代码总是知道它们在哪里。 他们的结束坐标是: line1:{ ...
  • 字体大小与文本的高度并不完全对应,它是一个有点任意的值,用于反映字体的大小。 不同风格的字体可能具有略微不同的实际尺寸,以使它们看起来大小相似。 除此之外,不同的浏览器稍微不同地计算字体大小,因此实际大小可能在浏览器之间有一个像素左右。 此外,字体大小不包括行高,默认情况下会增加20%的高度。 我通常用来在一个元素中垂直居中的一条线是将线高设置为元素的高度。 例: div { background: #eee; height: 50px; line-height: 50px; }
  • 在我看来,72dpi实际上是说72像素。 所以你的图像尺寸144 x 216实际上是你想要打印的尺寸。 UIImageView以点而不是像素测量的唯一原因是因为屏幕分辨率不同。 原版iPhone的屏幕大小与4s相同,但4s的屏幕上有更多的像素。 Apple使用了点数,因此更容易为所有设备编程。 看看这个链接: http : //www.scantips.com/basics1a.html我只是通读了它,我希望它能回答你的问题。 如果我更加困惑你,我道歉,我只是想帮忙! :) It looks to me t ...
  • 你可能只想使用find() ,例如 [row_indices, col_indices, values] = find(f==i) 如你所说,CoG坐标只是行和列索引的平均值,现在你有两个向量。 见mean() 。 You probably just want to use find(), e.g. [row_indices, col_indices, values] = find(f==i) The CoG coordinates are then, as you said, just the ave ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)