Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScript regex parts of file in specific format
    primarykey
    data
    text
    <p>Okay, I'm playing with some JavaScript regular expressions as a bit of practice and I've set myself the task of turning this text file into a json object:</p> <p><strong>Text file</strong>:</p> <pre><code>title: #HEY image: http://localhost:4089/assets/images/backgrounds/bg.jpg date: 2013-03-19 13:48:30 excerpt: The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. body: The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother\'s keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy My brothers. And you will know My name is the Lord when I lay My vengeance upon thee. Normally, both your ***** would be dead as ****** fried chicken, but you happen to pull this **** while I'm in a transitional period so I don\'t wanna kill you, I wanna help you. But I can\'t give you this case, it don\'t belong to me. Besides, I\'ve already been through too much **** this morning over this case to hand it over to your dumb ***. The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother\'s keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy My brothers. And you will know My name is the Lord when I lay My vengeance upon thee. </code></pre> <p><strong>into</strong> this:</p> <pre><code>{ title: '#HEY', image: 'http://localhost:4089/assets/images/backgrounds/bg.jpg', date: '2013-03-19 13:48:30', excerpt: 'The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother\'s keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy My brothers. And you will know My name is the Lord when I lay My vengeance upon thee. Normally, both your ***** would be dead as ****** fried chicken, but you happen to pull this **** while I'm in a transitional period so I don\'t wanna kill you, I wanna help you. But I can\'t give you this case, it don\'t belong to me. Besides, I\'ve already been through too much **** this morning over this case to hand it over to your dumb ***. The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother\'s keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy My brothers. And you will know My name is the Lord when I lay My vengeance upon thee. ' } </code></pre> <p>I figured regular expressions would be best for this (since it's a Node experiment) and currently I have this expression (which I'm sure can be greatly improved) but it has an issue with the body containing line breaks between paragraphs.</p> <pre><code>/^(.*)\: ?\n?(.*)/gim </code></pre> <p>How can I get it to select the whole body text instead of skipping the middle paragraph?</p> <p>[edit]</p> <p>To clarify, I'm not interested in the making json part, this isn't my question and not a problem, it's the regular expression that is the question.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload