I have a some lengthy text in a JS variable that I intend to pass to a html textbox but before that I want to trim it down to just the relevant text. If for instance I have this:
Subject_name: English, Teacher_name: John Doe, Remarks: some comment, Overall_marks:87,
Subject_name: Mathematics, Teacher_name: Doe John, Remarks: some comment, Overall_marks:75,
Subject_name: Science, Teacher_name: JD, Remarks: some comment, Overall_marks:80,
I want to replace "Teacher_name: John Doe, Remarks: some comment, "
with an empty string ""
so as to achieve:
Subject_name: English, Overall_marks:87,
Subject_name: Mathematics, Overall_marks:75,
Subject_name: Science, Overall_marks:80,
So basically I want to select "Teacher_name"
as the start, to "comment, "
as the end but I'm not really sure how to achieve that. The examples I'm seeing around and questions here on SO are for single characters which won't work in this case.
Such an example was - .replace(/H.*S/, '');
to replace everything between H and S with an empty string from this question
- I tried to use my start and end string selectors above which replaced everything from the very first start selector to the last occurence of the last selector, resulting in Subject_name: English, Overall_marks:80,
which is not what I need. Tried to put it in an array but resulted in random characters (not conversant with regex hence the chaos).
How can I achieve the replace I'm trying to implement?