Stack Exchange
Extract Letters and integers
I am trying to extract letters and integers from a itemValue in JS.The itemValue is fetched from a class.
@wire(ItemDetail, { itId: '$itemId' })
    wiredItemDetail({data,error}){
        if (data) {
            this.itemValue=data.itemValue;
       }

how can be this done?
letterChk = /[a-z]/i.exec(itemValue);
value =.itemValue.slice(letterCheck.index);

please help

What is the purpose for extraction?

you can try something like this:
let myString = 'a%b^c-d+e?123A2B';
let regex = /[^a-z]/gi;
let regexNums = /[^0-9]/g;
let result = myString.replace(regex, '');
let resultNums = myString.replace(regexNums, '');
console.log('result: %O', result) // prints: abcdeAB
console.log('resultNums: %O', resultNums) // prints: 1232

