我想將數(shù)字轉換為 * 并在每 4 位數(shù)字后添加空格。例如:12345678 -> 1234 5678 -> **** **** 現(xiàn)在我只是將數(shù)字轉換為 * 但不能添加空格。(將數(shù)字轉換為 * 時,添加空格功能不起作用)請幫幫我!import React, { Component } from 'react';import { Text, TextInput, View } from 'react-native';export default class PizzaTranslator extends Component { constructor(props) { super(props); this.state = {text: ''}; } render() { return ( <View style={{padding: 10}}> <TextInput style={{height: 40}} placeholder="Type here to translate!" onChangeText={(text) => this.setState({text})} value={this.state.text} /> <Text style={{padding: 10, fontSize: 42}}>{this.state.text.replace(/(\(-?\d+(?:\.\d*){4})/g,'$1').replace(/(^\s+|\s+$)/,'') .slice(20).padStart(this.state.text.length, '*')} </Text> </View> ); }}我期望輸入:123456789123 輸出:**** **** ****
如何將數(shù)字顯示為 **** ****
慕的地6264312
2021-12-02 16:37:34