Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Using a regexp to extract sequence fieldsby MCS (Monk) |
on Feb 13, 2006 at 15:02 UTC ( [id://529842]=note: print w/replies, xml ) | Need Help?? |
The problem (well not really a problem but given your example, a problem) with Regular Expressions is that they are very specific. In order for us to help you more, we need a little more information Are you just trying to match a specific line of text? (ie 'blabla2') or are you trying to match blabla[some number]? If you are looking for an exact string, your best bet is to use split (as per other examples here) and then iterate over the array (say a foreach) and compare each item to your string. Of course you say that 'anything' or 'blabla' are arbitrary sequences, I'm guessing you're not trying to match an exact string but rather a positional thing. In that case, use split and then you will have your data in an array and you can go to any position. $yourarray[2] for 'blabla2' $yourarray[0] for 'blabla1' etc... If you are looking for 'blabla#' where # is a number you can use the regex: $mystring =~ /blabla\d+/. If you need more information than I've provided, you're going to have to provide more information about your requirements.
In Section
Seekers of Perl Wisdom
|
|