Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
How to use Regex to break line after comma

I need to break line after comma using regex(another method is welcome too)

function breakLineAfterComma(){
    let Text = "This is an Example. Break Line Here"
    Text.replace('regex here')
    return Text;
}
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can use String.replace to replace all periods and a space with a newline:

function breakLineAfterComma(){
    let Text = "This is an Example. Break Line Here. Break Line Here"
    return Text.replace(/\. /g, "\n");
}

console.log(breakLineAfterComma())

You can also use String.replaceAll:

function breakLineAfterComma(){
    let Text = "This is an Example. Break Line Here. Break Line Here"
    return Text.replaceAll(". ", "\n");
}

console.log(breakLineAfterComma())

about 4 years ago · Juan Pablo Isaza Report

0

it's possible to use regex and replace "." with a break.

here is the reusable function example

function breakLineAfterComma(text){
    return text.replace(/\./g, '\n');
}

const content = "This is an Example. Break Line Here"
const a = breakLineAfterComma(content);
console.log(a);
about 4 years ago · Juan Pablo Isaza Report

0

function splitText(text){
  text = "This is an Example. Break Line Here";
  return text.split('. ').join('.\n');
// This is an Example. 
// Break Line Here
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!