Skip to content
Browse files

Avoid use of deprecated ereg

  • Loading branch information...
1 parent d76975b commit 0a98ecb6bad5e9214c9ef353b6a6cccb88bef5b4 @CloCkWeRX CloCkWeRX committed
Showing with 4 additions and 4 deletions.
  1. +1 −1 Chemistry/Atom.php
  2. +3 −3 Chemistry/Molecule_XYZ.php
View
2 Chemistry/Atom.php
@@ -63,7 +63,7 @@ class Science_Chemistry_Atom {
* @see setCoordinates()
*/
function Science_Chemistry_Atom($element, $coords="") {
- if ($element && ereg("[[:alpha:]]{1,2}", $element))
+ if ($element && preg_match("/[[:alpha:]]{1,2}/", $element))
$this->element = $element;
else
return null;
View
6 Chemistry/Molecule_XYZ.php
@@ -77,11 +77,11 @@ function parseXYZ($xyzdata, $src) {
// first line is number of atoms
$this->num_atoms = trim($line[0]);
// second line is molecule name and energy
- ereg("^([[:alnum:].]+)[[:space:]]+([[:digit:].-]+)",trim($line[1]),&$re);
+ preg_match("/^([[:alnum:].]+)[[:space:]]+([[:digit:].-]+)/",trim($line[1]),&$re);
$this->name = trim($re[1]);
$this->energy = trim($re[2]);
for ($i=2; $i<count($line); $i++) {
- if (!ereg("^#",$line[$i]) && !ereg("^$", $line[$i])) {
+ if (!preg_match("/^#/",$line[$i]) && !preg_match("/^$/", $line[$i])) {
$this->atoms[] = $this->parseAtom($line[$i]);
}
}
@@ -96,7 +96,7 @@ function parseXYZ($xyzdata, $src) {
* @see parseXYZ()
*/
function parseAtom($line) {
- list($element, $x, $y, $z) = split("[\t ]+",trim($line));
+ list($element, $x, $y, $z) = preg_split("/[\t ]+/",trim($line));
return new Science_Chemistry_Atom($element, array($x, $y, $z));
}

0 comments on commit 0a98ecb

Please sign in to comment.
Something went wrong with that request. Please try again.