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 Link to comment https://forums.phpfreaks.com/topic/143068-solved-simple-regex/ 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. Link to comment https://forums.phpfreaks.com/topic/143068-solved-simple-regex/#findComment-750321 Share on other sites More sharing options...
marcus Posted January 30, 2009 Author Share Posted January 30, 2009 works like a charm, thank you. Link to comment https://forums.phpfreaks.com/topic/143068-solved-simple-regex/#findComment-750324 Share on other sites More sharing options...
corbin Posted January 30, 2009 Share Posted January 30, 2009 No prob. ;p Link to comment https://forums.phpfreaks.com/topic/143068-solved-simple-regex/#findComment-750330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.