×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

eregi_replace and other regex's

eregi_replace and other regex's

eregi_replace and other regex's

(OP)
I am having trouble working with the regi_replace and eregi_replace functions.

I have a mySQL dbase that I read a time from. The time is inputed in the form hms, or hours minutes seconds. When I read the value from that field, I get some huge number, such as 33045, meaning it is 3:30 and 45 seconds.

I am wondering how I can use the above mentioned functions or another function to extract the first number, the second and third numbers, and the fourth and fifth numbers.

Any help is appreciated.

Thanks,

-Vic

vic cherubini
malice365@hotmail.com
www.epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
Wants to Know: Java, Cold Fusion, Tcl/TK
====

RE: eregi_replace and other regex's

If all you want to do is extract pieces of the field, why are you using "_replace" functions?  Why not use "substr" like:

  $huge_number = 33045;
  $hours = substr($huge_number,0,1);
  $minutes = substr($huge_number, 1,2);
  $seconds = substr($huge_number,3,2);

I'm sure there's a more efficient way to do that, but regi_replace and eregi_replace seem like the wrong choices to me.


Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

RE: eregi_replace and other regex's

(OP)
Ahh, I see now.

Thanks a bunch for that, I was not thinking clearly when I tried to use the other functions.

It worked perfectly. Thanks,

-Vic


vic cherubini
malice365@hotmail.com
www.epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close