RE: help in variable pattern matching





Thanks every one that helps. I find my problem. Now how
can I have a $pattern that contain some special characters
to pass it into regex?


I want to extract the line that contains either
RAID-5 N/Grp'd
Or
BCV N/Asst'd


The following code didn't work.
========================================================

My $type = $ARGV[1]

my $match = ( $type eq 'bcv' ) ? 'BCV' : 'RAID-5' ;
my $pattern = ( $type eq 'bcv' ) ? "${match}\s+N\/Asst" :
"${match}\s+N\/Grp" ;

while ( <DATA> ) {
next unless /$pattern/;
print $_ ;

}

__DATA__
05F3 Not Visible ???:? 16A:CF RAID-5 N/Grp'd RW 9492
05F5 Not Visible ???:? 16A:D10 RAID-5 N/Grp'd RW 9492
0031 Not Visible ???:? 01C:C0 2-Way Mir N/Grp'd RW 9492
05FA Not Visible ???:? 16A:D0 BCV N/Asst'd RW
9492
05FC Not Visible ???:? 01A:C0 BCV N/Asst'd RW
9492
.



Relevant Pages

  • Re: Regex question
    ... structure of the date you're trying to extract. ... For example, in Regex you can ... pattern that will ensure a valid date within the range allowed by T-SQL ... valid date from a string. ...
    (microsoft.public.dotnet.languages.csharp)
  • RegEx
    ... I want to use RegEx to parse a text string (I want to extract the tables ... The definition of the search pattern can be described as ... Dim regex, Match, Matches, Patrn, strText ' Create variable. ...
    (microsoft.public.scripting.vbscript)
  • RE: HowTo? RegEx - pattern to exclude the whole word
    ... I am trying to extract the pattern like this: ... SUB: this text I want to extract LOT: 2345, something in between, new ... Obviously, something in this regex tells it to be "greedy", and I need ...
    (microsoft.public.dotnet.general)
  • Re: Regex pattern help
    ... |>I've got this pattern that I am using but how would I incorporate ... | group so that is isn't interpreted as a special characters (such as the ...
    (alt.php)
  • RE: RegEx HELP!!!
    ... Assuming the pattern starts with an XY and then is followed by one or more ... *digitsequence, the following RegEx can be used to extract the specified ...
    (microsoft.public.dotnet.languages.csharp)