<?xml version="1.0" encoding="windows-1252"?>
<node id="937914" title="Re^3: RegEx related line split" created="2011-11-14 05:30:30" updated="2011-11-14 05:30:30">
<type id="11">
note</type>
<author id="401112">
johngg</author>
<data>
<field name="doctext">
&lt;p&gt;Do you mean that the opening parenthesis is optional in the text you are [doc://split]ing? If so, you can use a '&lt;c&gt;?&lt;/c&gt;' quantifier to make the opening parenthesis "zero or one of" but you also have to use a negative look behind to make sure you don't split '(' from 'a)'. I've added the '&lt;c&gt;x&lt;/c&gt;' modifier to the pattern so I can space it out and make it more readable.&lt;/p&gt;
&lt;code&gt;
knoppix@Microknoppix:~$ perl -E '
&gt; $line = q{(a) Line 1. b) Line 2. (c) Line 32. d) Line 42.};
&gt; @arr  = split m{ (?&lt;! \( ) (?= \(? [a-z] \) ) }x, $line;
&gt; say qq{&gt;$_&lt;} for @arr;'
&gt;(a) Line 1. &lt;
&gt;b) Line 2. &lt;
&gt;(c) Line 32. &lt;
&gt;d) Line 42.&lt;
knoppix@Microknoppix:~$ 
&lt;/code&gt;
&lt;p&gt;I hope this is helpful.&lt;/p&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-401112"&gt;
&lt;p&gt;Cheers,&lt;/p&gt;&lt;p&gt;JohnGG&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
937621</field>
<field name="parent_node">
937859</field>
</data>
</node>
