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



Result :

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

I used : (;)

This is what i did :

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