#!/usr/bin/perl
@lines = `perldoc -u -f atan2`;
foreach (@lines) {
s/\w<([^>]+)>/\U$1/g;
print;
}
How will the expression s/\w<([^>]+)>/\U$1/g;work?
The substitution does this:
s/
\w< # look for a single alphanumeric character followed by <
([^>]+) # capture one or more characters that are not <
> # followed by a >
/ ### replace with
\U # change following text to uppercase
$1 # the captured string from above
/gx # /g means do this as many times as possible per line
I added the /x modifier to be able to visualize the regex. The character class [^>] is negated, as denoted by the ^ character after the [, which means "any character except >".
For example, in the output from the perldoc command
X<atan2> X<arctangent> X<tan> X<tangent>
Is changed to
ATAN2 ARCTANGENT TAN TANGENT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With