in reply to Re^2: How can I test for the representation of an integer?
in thread How can I test for the representation of an integer?
Hi sm@sh,
I'm not quite sure I understand yet, could you provide some more context? Are you trying to determine whether a regex had capture groups or not? If so, how about this?
"1" =~ /1/; print @->1?"yes\n":"no\n"; "1" =~ /(1)/; print @->1?"yes\n":"no\n"; __END__ no yes
This uses the special variable @-, aka @LAST_MATCH_START.
Update 2018-09-01: Actually, @+ will give you the number of capture groups! See my reply below for the difference.
Regards,
-- Hauke D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How can I test for the representation of an integer?
by sm@sh (Acolyte) on Apr 25, 2016 at 11:12 UTC | |
by Corion (Patriarch) on Apr 25, 2016 at 12:05 UTC | |
by haukex (Archbishop) on Apr 25, 2016 at 11:53 UTC | |
by haukex (Archbishop) on Sep 01, 2018 at 14:27 UTC |