Good catch re. the s modifier, I missed that. Thanks for the correction.
With regard to your second point, from the way the OP initialised $code I don't think always ending with a newline was the requirement s/he was addressing. For the more general case you are correct.
Cheers, JohnGG
| [reply] [d/l] [select] |
So I'm thankful for the help!
First off: deMize « he »
Second, I'm not sure what I did was the best way of going about things. What I'm doing is just building a CMS insertion page with as little markup as possible, where each section is contained in it's own div.
Response:
The first problem was getting each into their own div, which the lookahead helped. To accomplish this, it just ends the current div when it hits a new section (may be a subsection in the future).
The reason for removing the line breaks was because I was using that as a delimiter for the last section --- there is probably a better way of doing that with determining the end of the string in the RegEx (maybe $), but I need to replace those line breaks with HTML breaks anyhow.
The problem:
This means that it is going to be linear with no sub-divs. I might have to rethink that for later, because I might want to have something like this later:
[section]
[top]Top Data
[middle]Mid Data
[bottom]Bottom Data
[section]
[top]Top Data
[bottom]Bottom Data
Should result to:
<div class="section">
<div class="top">Top Data</div>
<div class="middle">Middle Data</div>
<div class="bottom">Bottom Data</div>
</div>
<div class="section">
<div class="top">Top Data</div>
<div class="bottom">Bottom Data</div>
</div>
What I plan to do is store either the sub sections in an array or the sections in an array. I could probably use help with a better algorithm.
The whole purpose of this was so that I could quickly type the data into one input box, without building a whole intricate interface (that can come later).
| [reply] [d/l] [select] |
[section]
top=Top Data
middle=Mid Data
bottom=Bottom Data
[section]
top=Top Data
bottom=Bottom Data
Now you've got a built-in qualitative difference that makes the parsing easier. | [reply] [d/l] |