marcus Posted January 30, 2009 Share Posted January 30, 2009 since the php regex forum doesn't seem to be ever-so popular i'd figure i would post here personally i suck when it comes to regular expressions, so if anybody could lead me to a path where i can help understand them it would be great... anyone, my problem is: i'm trying to convert such variables like x^y so that ^y would turn into <sup>y</sup> So if the user inputted x^2 + 5x - 4 the output in HTML would read x<sup>2</sup> + 5x - 4, and along with more exponents like: x^3 + 3x^2 + 4x - 2 would be x<sup>3</sup> + 3x<sup>2</sup> + 4x - 2 Quote Link to comment Share on other sites More sharing options...
corbin Posted January 30, 2009 Share Posted January 30, 2009 /([a-z])\^([\d]+)/ \1<sup>\2</sup> By the way, the regexp forum will never be popular if no one posts in it. Quote Link to comment Share on other sites More sharing options...
marcus Posted January 30, 2009 Author Share Posted January 30, 2009 works like a charm, thank you. Quote Link to comment Share on other sites More sharing options...
corbin Posted January 30, 2009 Share Posted January 30, 2009 No prob. ;p Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.