RE: [PHP] Regular Expressions? Help!
| From: | Rick Emery | Date: | Mon, 25 Mar 2002 21:10:54 +0000 |
| Subject: | RE: [PHP] Regular Expressions? Help! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-90099@lists.php.net to get a copy of this message | ||
Do this.
Execute the command at the command line and re-direct output to a file: xxx.
Open file xxx with an editor, such as vi. Is there a blank line, or line
with JUST a carriage-return (\n) as the last line?
-----Original Message-----
From: Walker, Roy [mailto:Roy.Walker@GEZWM.com]
Sent: Monday, March 25, 2002 3:09 PM
To: 'Rick Emery'; 'php-general@lists.php.net'
Subject: RE: [PHP] Regular Expressions? Help!
No. I think there is a carriage return (\n), but there is not a blank line
at the end.
-----Original Message-----
From: Rick Emery [mailto:remery@excel.com]
Sent: Monday, March 25, 2002 3:07 PM
To: 'Walker, Roy'; 'php-general@lists.php.net'
Subject: RE: [PHP] Regular Expressions? Help!
When the exec'd program executes from the command line, does it output a
blank line as its last line?
-----Original Message-----
From: Walker, Roy [mailto:Roy.Walker@GEZWM.com]
Sent: Monday, March 25, 2002 2:05 PM
To: 'php-general@lists.php.net'
Subject: RE: [PHP] Regular Expressions? Help!
I just realized why nothing I was trying for the regular expressions wasn't
working. The command I am running is a C program on the command line of a
Linux box. I can't capture the output, it just gets output onto the screen.
I just echo'd $output after the command was run and it was empty. Any
ideas?
-----Original Message-----
From: Rick Emery [mailto:remery@excel.com]
Sent: Monday, March 25, 2002 1:54 PM
To: 'Walker, Roy'
Subject: RE: [PHP] Regular Expressions? Help!
well, ya might try:
$my_array = explode( "\" ",$output);
this would set:
$my_vars[0] = "variable1:\"some text info\""
$my_vars[1] = "variable2:\"some text info\""
then, you can do an explode on each of the my_vars
another, which might work:
<?php
$output = "variable1:\"some information\" variable2:\"some
information\"";
ereg( "(variable[0-9]*):\"(.*)\" (variable[0-9]*):\"(.*)\"", $output,
$regs);
print "output = $output\n";
print $regs[0]." - 0\n";
print $regs[1]." - 1\n";
print $regs[2]." - 2\n";
print $regs[3]." - 3\n";
print $regs[4]." - 4\n";
?>
WHEN EXECUTED DISPLAYS THIS:
C:\>php -q zz.php\
output = variable1:"some information" variable2:"some information"
variable1:"some information" variable2:"some information" - 0
variable1 - 1
some information - 2
variable2 - 3
some information - 4
-----Original Message-----
From: Walker, Roy [mailto:Roy.Walker@GEZWM.com]
Sent: Monday, March 25, 2002 1:31 PM
To: 'Rick Emery'
Subject: RE: [PHP] Regular Expressions? Help!
There will be a specific number of variables returned. I just wanted to set
all the output to a string and just run through it to grab the variables.
Thanx
-----Original Message-----
From: Rick Emery [mailto:remery@excel.com]
Sent: Monday, March 25, 2002 1:28 PM
To: 'Walker, Roy'; 'php-general@lists.php.net'
Subject: RE: [PHP] Regular Expressions? Help!
With there be a specifc number of variables returne? Or can the number of
variables vary?
-----Original Message-----
From: Walker, Roy [mailto:Roy.Walker@GEZWM.com]
Sent: Monday, March 25, 2002 1:26 PM
To: 'php-general@lists.php.net'
Subject: [PHP] Regular Expressions? Help!
I am trying to do a match for an expression and it to a variable from the
output of a command:
<?php
$lines = file ($file);
while (list ($line_num, $line) = each ($lines)) {
$trimline = trim ($line);
$output = shell_exec ("$prog $cmdline $trimline &");
}
?>
How can look through $output to set the information returned as different
variables the output would look like:
variable1:"some information" variable2:"some information"
I want to set each variable to a string and write it to a file.
Thank You for you help.
Roy
************************** PLEASE NOTE **************************
This E-Mail/telefax message and any documents accompanying this transmission
may contain privileged and/or confidential information and is intended
solely for the addressee(s) named above. If you are not the intended
addressee/recipient, you are hereby notified that any use of, disclosure,
copying, distribution, or reliance on the contents of this E-Mail/telefax
information is strictly prohibited and may result in legal action against
you. Please reply to the sender advising of the error in transmission and
immediately delete/destroy the message and any accompanying documents.
Thank you.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
************************** PLEASE NOTE **************************
This E-Mail/telefax message and any documents accompanying this transmission
may contain privileged and/or confidential information and is intended
solely for the addressee(s) named above. If you are not the intended
addressee/recipient, you are hereby notified that any use of, disclosure,
copying, distribution, or reliance on the contents of this E-Mail/telefax
information is strictly prohibited and may result in legal action against
you. Please reply to the sender advising of the error in transmission and
immediately delete/destroy the message and any accompanying documents.
Thank you.
************************** PLEASE NOTE **************************
This E-Mail/telefax message and any documents accompanying this transmission
may contain privileged and/or confidential information and is intended
solely for the addressee(s) named above. If you are not the intended
addressee/recipient, you are hereby notified that any use of, disclosure,
copying, distribution, or reliance on the contents of this E-Mail/telefax
information is strictly prohibited and may result in legal action against
you. Please reply to the sender advising of the error in transmission and
immediately delete/destroy the message and any accompanying documents.
Thank you.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
************************** PLEASE NOTE **************************
This E-Mail/telefax message and any documents accompanying this transmission
may contain privileged and/or confidential information and is intended
solely for the addressee(s) named above. If you are not the intended
addressee/recipient, you are hereby notified that any use of, disclosure,
copying, distribution, or reliance on the contents of this E-Mail/telefax
information is strictly prohibited and may result in legal action against
you. Please reply to the sender advising of the error in transmission and
immediately delete/destroy the message and any accompanying documents.
Thank you.
************************** PLEASE NOTE **************************
This E-Mail/telefax message and any documents accompanying this transmission
may contain privileged and/or confidential information and is intended
solely for the addressee(s) named above. If you are not the intended
addressee/recipient, you are hereby notified that any use of, disclosure,
copying, distribution, or reliance on the contents of this E-Mail/telefax
information is strictly prohibited and may result in legal action against
you. Please reply to the sender advising of the error in transmission and
immediately delete/destroy the message and any accompanying documents.
Thank you.
************************** PLEASE NOTE **************************
This E-Mail/telefax message and any documents accompanying this transmission
may contain privileged and/or confidential information and is intended
solely for the addressee(s) named above. If you are not the intended
addressee/recipient, you are hereby notified that any use of, disclosure,
copying, distribution, or reliance on the contents of this E-Mail/telefax
information is strictly prohibited and may result in legal action against
you. Please reply to the sender advising of the error in transmission and
immediately delete/destroy the message and any accompanying documents.
Thank you.
************************** PLEASE NOTE **************************
This E-Mail/telefax message and any documents accompanying this transmission
may contain privileged and/or confidential information and is intended
solely for the addressee(s) named above. If you are not the intended
addressee/recipient, you are hereby notified that any use of, disclosure,
copying, distribution, or reliance on the contents of this E-Mail/telefax
information is strictly prohibited and may result in legal action against
you. Please reply to the sender advising of the error in transmission and
immediately delete/destroy the message and any accompanying documents.
Thank you.