robcrozier Posted January 17, 2008 Share Posted January 17, 2008 Hi, i wonder if anyone could tell me how i could find a non specific substring of a given string. Basically i want to find a 5-digit integer value within a long string. I know that there will only be one 5-digit integer within the string so i suppose this makes it possible, i'm just not sure how to go about it? I know that substr() will work if you know what the substring actually is (i.e '12345' as oppose to a 5-digit unspecified integer) Any suggestion would be great as it's doing my head in. Thanks Link to comment https://forums.phpfreaks.com/topic/86483-find-an-unspecific-substring/ Share on other sites More sharing options...
tinker Posted January 17, 2008 Share Posted January 17, 2008 look at this and that, also any of the others, then try something like: if (preg_match("/[0-9]/",$s)) { echo "A match was found."; } else { echo "A match was not found."; } There is a regex forum here somewhere... Link to comment https://forums.phpfreaks.com/topic/86483-find-an-unspecific-substring/#findComment-441920 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.