in reply to Match variables : Beginner in perl
Let's start from choroba's answer (note: I prefere square brackets to print variables): see it here live at WebPerl (WebPerl kindly provided by haukex)
The above works as you expected. But be careful with the * quantifier: it's greedy, very greedy! Learn about greediness at ModernPerl book .. well read all the book as side book while learning perl: it is not designed for beginner but is a great book, and free!
Also notice that you worked on a positive match, but you can also do the opposite: work on negative matches, ie match all non spaces \S like in this example
haukex was so kind to provide also a regex testing page: let's see our last regex against your string and another similar to choroba's one: regex live at webperl
As you can see there is a lot to play with!
HtH
PS if interested you can create links to webperl using my WebPerlizator - automating WebPerl (by haukex) page creation
L*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Match variables : Beginner in perl -- webperl
by Perl_Programmer1992 (Sexton) on Jan 03, 2019 at 09:18 UTC | |
by jbodoni (Monk) on Jan 03, 2019 at 11:26 UTC | |
by dsheroh (Monsignor) on Jan 03, 2019 at 11:40 UTC |