the pattern (\n|.)* and PHP Segmentation Fault

the pattern:

(\n|.)*

what it does:

this is a nice regular expression pattern that spans multiple lines.

example:

pattern used – <label>Address:(\n|.)*<label>Website:

<div id=’cominfo_hdr_div’>Company Information</div>¶
¶
<label>Address:</label><br>¶
33rd Flr. PBCom Tower, Ayala Ave., Corner Herrera St.<br>Makati City, Metro Manila <br><br>¶
<label>Website:
</label><br>¶
http://www.example.com <br><br> ¶
<label>More Information</label><br>¶


this is very useful for parsing text from data with a repeating pattern.  just queue up the data source in a loop, run the regular expression pattern through it and you should have that particular text you want in no time.  yes?

Nope!  at least for me it didn’t. it got me something else instead.

from my repeated manual tests using patterned strings spanning multiple lines similar to the example above, this regular expression would work.  however, when i started feeding the actual data for parsing in a loop, i got a PHP Segmentation Fault at some point. the data source isn’t that huge.  about 15 – 30 KB each in size, and close to a thousand.  sometimes it went through once or twice without an error, but after several iterations in the loop it always went down to a Segmentation Fault.

what seems to be the matter?

Similar Posts:

the pattern: (\n|.)* what it does: this is a nice regular expression pattern that spans multiple lines. example: pattern used – <label>Address:(\n|.)*<label>Website: <div id=’cominfo_hdr_div’>Company Information</div>¶ ¶ <label>Address:</label><br>¶ 33rd Flr. PBCom Tower, Ayala Ave., Corner Herrera St.<br>Makati City, Metro Manila <br><br>¶ <label>Website:</label><br>¶ http://www.example.com <br><br> ¶ <label>More Information</label><br>¶ — this is very useful for parsing text from…