Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PHP and Regular Expressions

Name: Anonymous 2007-06-15 14:38 ID:kQPwzXix

I'm not quite the EXPERT PROGRAMMER when it comes to regular expressions. I has a string:

$eq = "If the bobsled has to go 30 meters in 5 seconds starting from rest, then I think we could find the acceleration using: %eDeltax = (1/2) a t^2 + v_(0)te% Solving for acceleration would yield: %ea = 2(Deltax)/t^2e% since %ev_(0)e% is zero %ea = 2(30 m)/(5 s)^2 = 2.4e%%em/s^2e%";

I want to extract everything between the %e and e% using preg_match_all() but I don't do good with regular expressions - what would you do? I can perform this task using strlen(), strpos() and strtr() but this seems like terrible overkill

Name: Anonymous 2007-06-15 17:33 ID:cFDMIznG

It should be "(?<=%e)(.*?)(?=%e)".

| the '?' makes '.*' match as many characters as possible instead of as few as possible (which is the default).

Other way around.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List