Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
420 views
in Technique[技术] by (71.8m points)

求正则表达式 整数五位数 小数两位数

(/^D*(d*(?:.d{0,2})?).*$/g, '$1')
这个只能限制小数两位数 综合限制整数不超过五位数怎么写 (?_?)TIM截图20200424144033.png

<Form.Item style={{ margin: 0 }}>
          {form.getFieldDecorator(dataIndex, {
            initialValue: record[dataIndex],
            getValueFromEvent: (event) => {
              return event.target.value.replace(/^D*(d*(?:.d{0,2})?).*$/g, '$1')  // 这里应该怎么改?
            },
          })(
            <Input style={{width:"100px"}} initialvalue={this.state.inputValueDefault} ref={node => (this.input = node)} onPressEnter={this.save} onBlur={this.save} />)
          }
</Form.Item>

这是一个可编辑单元格 整数部分限制输入几位数,小数部分限制输入几位小数这种方法


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

这样应该就可以了

/^d{1,5}(.d{1,2}){0,1}$/

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...