Click to See Complete Forum and Search --> : exclude characters from counting?


ktsirig
November 10th, 2009, 08:20 AM
Hello, I wanted to ask if you have a string like:

$my_s='ASRGREGTGTR----REGREGRE+++RRRRRR....';


is there a way to count the length of the string, excluding non-word characters (+,- or .)?

thank you

PeejAvery
November 10th, 2009, 10:41 AM
You can create a temp string of only numbers and letters and count that.

$tmp = preg_replace('/[^0-9a-zA-Z]/i', '', $my_s);