Here is part of my actual code, if that makes any difference. $password // this var was retrieved from db $int_id // this var was retrieved from db
$file_array = file("$DOCUMENT_ROOT/dir/file.dat"); $count = count($file_array); if ($count == 0) echo "<p>No records found in .dat file.</p>"; for ($i = 0; $i < $count; $i++) { if (eregi("^\$password+[[:space:]]*+\$int_id", $file_array[$i])) { // do stuff } } Zach -----Original Message----- From: Edward van Bilderbeek - Bean IT [mailto:[EMAIL PROTECTED]] Sent: Friday, January 25, 2002 10:29 AM To: Zach Curtis Subject: Re: [PHP] Reg Exp Help but if the positions as fixed, why don't you use the substr, and then trim th result? Edward ----- Original Message ----- From: "Zach Curtis" <[EMAIL PROTECTED]> To: "Edward van Bilderbeek - Bean IT" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Friday, January 25, 2002 6:12 PM Subject: RE: [PHP] Reg Exp Help > The password and int_id begin and end in fixed positions. > > password begins in position 13 and can occupy up to 8 characters > int_id begins in position 21 and can occupy up to 4 characters > > Sometimes a password (or int_id) may occupy all of those fixed position or > only some of the fixed positions, it's variable. > > > Zach > > -----Original Message----- > From: Edward van Bilderbeek - Bean IT [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 25, 2002 9:58 AM > To: Zach Curtis > Subject: Re: [PHP] Reg Exp Help > > > how can I see that it isn't a 6 char $password with a 3 char $int_id ?? > > > This one has a 8 character $password, followed by zero white spaces, > > followed by a single character $int_id > > 7d2ad345b > > Edward > > > ----- Original Message ----- > From: "Zach Curtis" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, January 25, 2002 5:51 PM > Subject: [PHP] Reg Exp Help > > > > I am trying to code a regular expression that will match at the beginning > of > > the string the contents of $password, followed by 0 or more occurrences of > > white space, followed by the contents of $int_id. The match should be case > > insensitive. > > > > Here are some examples of the strings: > > > > This one has a 6 character $password, followed by two white spaces, > followed > > by a single character $int_id > > 9a9b9c z > > > > This one has a 8 character $password, followed by zero white spaces, > > followed by a single character $int_id > > 7d2ad345b > > > > This one has a 5 character $password, followed by three white spaces, > > followed by a four character $int_id > > d22ad bbaw > > > > > > Here is the regular expression I am trying to use that does not find the > > match and produces "Warning: REG_BADRPT". > > > > (eregi("^\$password+[[:space:]]*+\$int_id", $file_array[$i])) > > > > Any corrections? Thanks in advance. > > > > > > Zach Curtis > > POPULUS > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]