poe Posted November 12, 2006 Share Posted November 12, 2006 i will have a string that is for sports scores and is shown as:outcome(w,l,t,so,nd) team score : opp scoreso it would look like:[a-z] [0-9] : [0-9]ie. w14:3OR l16:21OR so4:3OR t6:6 etc...i want to add a `:` after the outcomeie.. w:7:3how do i add a : after the alpha charactert(s) Link to comment https://forums.phpfreaks.com/topic/26993-extract-only-alpha-characters-from-a-string/ Share on other sites More sharing options...
sinisake Posted November 12, 2006 Share Posted November 12, 2006 Can be done on this way:[code]<?php$stringi="w14:3";$patern="^[a-z]+";if(eregi($patern,$stringi,$match)){$match=implode("",$match);$replace=$match.":";$stringi=eregi_replace($match,$replace,$stringi);echo ($stringi);}?>[/code] Link to comment https://forums.phpfreaks.com/topic/26993-extract-only-alpha-characters-from-a-string/#findComment-123447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.