ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:
In this case I got: /a/b/[RED]c[/RED]/[RED]d[/RED].# Given path: /a/b/c/d # Given regex: ^/a/b/([^/]*)/([^\/]*) # Output: /a/b/\033[1;31mc\033[0m/\033[1;31md\033[0m
The @captures contains the group values that were captured (c and d in the example). I came a cross with the Term::ANSIColor module which can help me color the string without writing the color codes myself.foreach $regex_href (@rexes) { %regex = %{$regex_href}; if (@captures = ($path =~ /$regex{'regex'}/)) { # Do logic } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to color the regex captured groups?
by hv (Prior) on Aug 12, 2022 at 17:31 UTC | |
|
Re: How to color the regex captured groups?
by tybalt89 (Monsignor) on Aug 12, 2022 at 17:46 UTC | |
|
Re: How to color the regex captured groups?
by hippo (Archbishop) on Aug 13, 2022 at 10:38 UTC | |
|
Re: How to color the regex captured groups?
by kcott (Archbishop) on Aug 13, 2022 at 05:15 UTC |