Hello all,
I was writing a little regex for a pattern i had on my hands and realized that I wasn't sure how it would wind up working. So I wrote myself a little test:
use strict; use diagnostics; while( <DATA> ) { my @list = (); if( @list = ( $_ =~ m|^rs://([-\w]+)(?:\.([-\w]+))+|) ) { print join( ' > ', @list ), "\n"; } } __DATA__ rs://a rs://b.c rs://d.e.f rs://g.h.i.j.k
so it's looking to match a pattern that is a word followed by one or more words, with periods in between them. Here's what I got back from the output:
b > c d > f g > k
I was kind of hoping it would give me back the whole
b > c d > e > f g > h > i > j > k
which is of course what split() could do for me, but i didn't see that right away. But now i'm left wondering what happened to all of the other values "in the middle" that matched. The regex seems to just have overwritten them.
In reply to Regex Matching Oddity by AidanLee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |