infocrasher infocrasher - 9 months ago 36
Node.js Question

Divide String REGEX

I want to writre a Regular Expression to divide these two lines into rows

Example

1;John;Doe;45
2;jaja;dada;23

Result :

ID : 1
Name : John
Last name : Doe
Age : 45


I used : (;)

This is what i did : https://regex101.com/r/By1Ei1/1

Answer Source

Your regex is almost correct, however it does not break the line when a space is encountered, so 45 and 2 appear on the same line, to fix this just add a space with ; in square brackets. And use the \n subtitution like you did!

([; ])

Run it here