I donít think regexp will help improve efficiency in this case. The requirement is very straight forward, and I believe everyone agrees that, any solution has to iterate thru the string (if you use regexp, regexp will do this), doesnít matter how quick or slow it is. Theoretically, in this case, for any reasonably efficient algorithm, including the best solution anyone would be able to find, t ~ o(l) stands true for all solutions (t is the time spent, and the length of the string is l, and t ~ o(l) means t is a linear function of l).
Considering regexp is more general, and most likely would do more than you want in a specific case. It is reasonable that a specific function you wrote would be faster than use regexp.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||