SOURCE

console 命令行工具 X clear

                    
>
console
let a = document.querySelector('.input')
a.addEventListener('input', b)
function b() {
    //    str=document.querySelector('.input')
    let str = a.value
    // console.log(arr[3],arr[7],arr[9])

    let user = new User(str);
    console.log(user.getOrderId(), user.getPayment())
}

class User {

    constructor(str) {
        let arr = str.split('\t')
        this.orderId = arr[3]
        this.payment = arr[7]
        // this.accountInfo = arr[9]
        this.accountInfo = this.matchInfo(arr[9])
    }


    matchInfo(str) {
        const nameRegex = /[\u4E00-\u9FFF]{2,4}/;
        const emailRegex = /\w+(-+.\w+)*@\w+(-.\w+)*.\w+(-.\w+)*/g;
        const accountRegex = /\d{11}/g;

        const nameMatch = str.match(nameRegex);
        const accountMatch = str.includes('@') ? str.match(emailRegex) : str.match(accountRegex);

        const info = {
            name: nameMatch[0] || '',
            account: accountMatch[0] || ''
        };


        console.log(info)
        return info;
    }

    getOrderId() {
        return this.orderId;
    }
    getPayment() {
        return this.payment;
    }
    getAccountInfo() {
        return this.accountInfo;
    }
    getUsername() {
        return this.accountInfo.name;
    }
    getAccount() {
        return this.accountInfo.account;
    }
}

<input class="input" type="text">