papaface Posted February 19, 2008 Share Posted February 19, 2008 Hello, Can someone please tell me how I would go about finding the first alphanumeric character in a string? Thank you Link to comment https://forums.phpfreaks.com/topic/91952-find-first-alphanumeric-character/ Share on other sites More sharing options...
craygo Posted February 19, 2008 Share Posted February 19, 2008 can try putting a couple functions together <?php $string = "Here! is some text, and numbers 12345, and symbols !£$%^&"; $new_string = preg_replace("/[^a-zA-Z0-9s]/", "", $string); $first_alpha = substr($new_string,0,1); echo $first_alpha; ?> Ray Link to comment https://forums.phpfreaks.com/topic/91952-find-first-alphanumeric-character/#findComment-470899 Share on other sites More sharing options...
effigy Posted February 19, 2008 Share Posted February 19, 2008 In terms of ASCII: <pre> <?php $data = '#(%*@(*$!*A1B'; preg_match('/[a-z\d]/i', $data, $matches); print_r($matches); ?> </pre> Link to comment https://forums.phpfreaks.com/topic/91952-find-first-alphanumeric-character/#findComment-470906 Share on other sites More sharing options...
papaface Posted February 19, 2008 Author Share Posted February 19, 2008 Thanks Link to comment https://forums.phpfreaks.com/topic/91952-find-first-alphanumeric-character/#findComment-470938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.