Try the {} notation, that says how many whats are required before the which (as it were). Perhaps something like:-
if (/.{31,33}\|[BNPG]\|/){ return 2; } Meaning, between 31 & 33 characters. Untested! HTH, GStC. -----Original Message----- From: Jason Balicki [mailto:[EMAIL PROTECTED] Sent: Friday, January 21, 2005 9:24 PM To: 'Perl Beginners List' Subject: How to find regex at specific location on line Hello, If you would, please consider the following input file: <code> |6643 |Jason Balicki | |0501211243|000:00:00| 0| S |0| | |13145551212 |N| | 0|001001|001001| 100| 10|B|A| </code> And the following code: <code> while(<>){ if (whichline($_) == 1){ print "input line is call record line 1\n"; } else { if (whichline($_) == 2){ print "input line is call record line 2\n"; } } } sub whichline { if (/\|[BNPG]\|/){ return 2; } else { if (/\|[0A-Z]\|$/) { return 1; } } } </code> You'll notice that regex "|[BNPG]|" which should match the |N| on the second line of the input file. That field will always be located on the 31st, 32nd and 33rd characters on the line. This regex works, and has been in use for a couple of days now, but I'd like to be more explicit, especially since I can never be sure that another line of input won't contain that string (I am filtering from a serial port that will have other output.) If I can pin it to a specific location, it would at least be a little better. Is there a way that I can specify that that regex starts on a particular character on the line? Thanks very much for any input. --J(K) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>