in reply to Efficient regex search on array table
I'm not sure if this will buy you any improvements, but you might try the qr operator. You might even already be using qr depending on what &composeRegex returns.
Quoting from the documentation:
qr/STRING/msixpodualnThis operator quotes (and possibly compiles) its STRING as a regular expression. STRING is interpolated the same way as PATTERN in m/PATTERN/.
I think this example (also from the documentation) gives a good idea of what is possible.
my $sentence_rx = qr{ (?: (?<= ^ ) | (?<= \s ) ) # after start-of-string or # whitespace \p{Lu} # capital letter .*? # a bunch of anything (?<= \S ) # that ends in non- # whitespace (?<! \b [DMS]r ) # but isn't a common abbr. (?<! \b Mrs ) (?<! \b Sra ) (?<! \b St ) [.?!] # followed by a sentence # ender (?= $ | \s ) # in front of end-of-string # or whitespace }sx; local $/ = ""; while (my $paragraph = <>) { say "NEW PARAGRAPH"; my $count = 0; while ($paragraph =~ /($sentence_rx)/g) { printf "\tgot sentence %d: <%s>\n", ++$count, $1; } }
I hope this helps, even if only a little.
Cheers,
Brent
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Efficient regex search on array table
by Polyglot (Chaplain) on Dec 15, 2022 at 05:35 UTC | |
by kcott (Archbishop) on Dec 16, 2022 at 04:16 UTC | |
|
Re^2: Efficient regex search on array table
by Polyglot (Chaplain) on Dec 15, 2022 at 03:00 UTC |