mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-31 11:05:36 +00:00
Update 20. 表示数值的字符串.md
题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 20. 表示数值的字符串
|
||||
|
||||
[牛客网](https://www.nowcoder.com/practice/e69148f8528c4039ad89bb2546fd4ff8?tpId=13&tqId=11206&tab=answerKey&from=cyc_github)
|
||||
[Leetcode](https://leetcode.cn/problems/biao-shi-shu-zhi-de-zi-fu-chuan-lcof/)
|
||||
|
||||
## 题目描述
|
||||
|
||||
@@ -41,9 +41,9 @@ false
|
||||
```
|
||||
|
||||
```java
|
||||
public boolean isNumeric (String str) {
|
||||
if (str == null || str.length() == 0)
|
||||
public boolean validNumber(String s) {
|
||||
if (s == null || s.length() == 0)
|
||||
return false;
|
||||
return new String(str).matches("[+-]?\\d*(\\.\\d+)?([eE][+-]?\\d+)?");
|
||||
return s.trim().matches("[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?");
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user