in reply to "Capturing the nth word in a string" Algorithm Analysis
The conclusion is that split is more efficient on breaking up a string than using regular expression.This is a quibble on perl internals. Split's first argument is always, one hundred percent of the time time a regular expression. Ninety-nine percent of the time the expression is given literally to split whether as a string literal (split "\\s+") or a plain expression (split /\s+/). When given the string literal ' ' split really, truely does use /\s+/. (it also does a quick skip of leading whitespace). In that sense split can't be said to be that different from a regex since it internally uses the regex engine all the time.
Quibble off.
|
|---|