kts Posted January 30, 2008 Share Posted January 30, 2008 I was recently advised and helped with a code to remove the last #'s on an id. ex: 21_75_39 -> 21_75 the code i was presented was: preg_replace('#_[\d]+$#', '', "21_75_8484"); I was wondering if someone can simply explain how it works, im not familiar with preg_replace, but i love how it worked Thanks. Quote Link to comment Share on other sites More sharing options...
effigy Posted January 30, 2008 Share Posted January 30, 2008 # -- Starting delimiter _ -- Literal underscore [\d]+ -- One or more digits; this can be reduced to \d+ $ -- End of line anchor # -- Ending delimiter Quote Link to comment Share on other sites More sharing options...
kts Posted January 30, 2008 Author Share Posted January 30, 2008 Thank you sir, this has inspired me to learn more on regex, but you cleared up the "mystery" for me thanks again! Quote Link to comment Share on other sites More sharing options...
laffin Posted January 30, 2008 Share Posted January 30, 2008 Use what I use Expresso Regex Developement tool even if ya dun understand regex completely, this tool helps a lot Quote Link to comment Share on other sites More sharing options...
kts Posted January 30, 2008 Author Share Posted January 30, 2008 interesting, ill check out the tool... i would probobly rather just learn the syntax, but it may help Quote Link to comment Share on other sites More sharing options...
laffin Posted January 31, 2008 Share Posted January 31, 2008 believe me it does help out a lot 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.