DotDragnet
May 24, 2012, 05:32:27 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Mobile users - Our forum is Tapatalk enabled. http://www.tapatalk.com/
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: numbers regex  (Read 219 times)
Charisma Bypass
Hero Member
*****
Posts: 556



View Profile Awards
« on: July 15, 2011, 06:53:27 PM »

Is there a nice and easy regex I can use to strip the numbers off the *end* of a string?

Eg; 

W1NPPP34

would become W1NPPP

Been hunting google and only come across convoluted methods.  Easy to strip out all the numbers of course, but that doesn't fit the need Sad

Thanks in advance
Logged
JasonD
Global Moderator
Hero Member
*****
Posts: 551



View Profile Awards
« Reply #1 on: July 15, 2011, 08:04:10 PM »

Code:
rtrim($foo, '0..9')

Or \d+$ for a regex
Logged
Charisma Bypass
Hero Member
*****
Posts: 556



View Profile Awards
« Reply #2 on: July 17, 2011, 11:25:01 AM »

I never knew rtrim could do that.  Thank you very much Jason.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2008, Simple Machines Valid XHTML 1.0! Valid CSS!