Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to split paragraphs/object in DOM with react

How can i split the context for say if i have the following example? I want to only extract this sentence "Our client, a highly respected moving company is seeking a National Account Move Coordinator to join their team based remotely."

<article>
Our client, a highly respected moving company is seeking a National Account Move Coordinator to join their team based remotely.
<br>
<br>
The successful candidate will have experience within the Household Goods Moving and Relocation Industry.
<br>
<br>
<strong>National Account Move Coordinator responsibilities:</strong>
</article>

This is my code at the moment but it does not pull the sentence that i wanted… it pull everything instead..

const body =
    'We are hiring for the following opportunity:  \n' +
    job.title + ' - ' + job.location + ' \n' +
    job?.description.replace(/<[^>]*>?/gm, '').replace('&nbsp;', ' ').split("<br><br>")[0] + '... \n\n';

Please help..

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Well something like this will do

YourArticleSelector.innerText should return all the text without the HTML tags something like

Our client, a highly respected moving company is seeking a National Account Move Coordinator to join their team based remotely.\n
\n\n
The successful candidate will have experience within the Household Goods Moving and Relocation Industry.\n
\n\n
National Account Move Coordinator responsibilities

Now you can just

job.description.split(/\n\n/g)[0].trim()

You should get what you want

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading