0

Here is my output

Here is my code, here i am changing arrayItem.replace("\u001bE", "") my problem is i want to change for another string also "\x1B-1" --> how to declare this in my code replacing multiple strings at a time.

 const file = files[0];
 let reader = new FileReader();
 const fruits = [];
 reader.onload = (e) => {
 const file = e.target.result;
 const lines = file.split(/\r\n|\n/);
 //console.log(lines.length);
 textarea.value = lines.join('\n');
 lines.forEach(function (arrayItem) {
 //console.log(arrayItem.replace("\u001bE", "<b>"));
 var arr1 = arrayItem.replace("\u001bE", "<b>");
 var arr2 = arr1.replace("\u001bF", "</b>");
 fruits.push(arr2);
 });
 console.log(fruits.length);
 if (parseInt(fruits.length) > 0) {
 console.log(fruits);
 txtreplace.innerHTML = fruits;
 }
 };
 reader.onerror = (e) => alert(e.target.error.name);
 reader.readAsText(file);
 });
 }, false);
asked Jul 23, 2022 at 5:01

1 Answer 1

1

Not sure if this is what you're asking but you can chain multiple calls to replace like this:

var arr1 = arrayItem.replace("\u001bE", "<b>").replace("\x1B-1", "<something>");
answered Jul 23, 2022 at 5:13
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.