what I want is something like this / ([^ ]*?)<\/TD>/ but [^ ] not working,is there any way to slove this?thanks
hi,thanks for your reply I tried \s before, not working here is the source code I want to parse I want to get the country name,you can see there is before country name,that's good,but the country name United States has a space,it's different from ,I think,so maybe I can get the country name without problem if I can find a way to exlude
Why don't you use strrchr? It should be faster than your regex. It catches the last occurance of the "needle". You can use str_(i)replace to remove the leading ' ' and the traling '</td>'. $str = '<td class="Bold" align="CENTER">Decatur, GA 30030 United States</td>'; echo str_ireplace(array(' ', '</td>',), '', (strrchr($str, ' '))); PHP:
thanks,bogi,I finally figure it out myself,actually exclude ; in the string is enough,before I thought I need to exclude