cgimusic Posted September 15, 2008 Share Posted September 15, 2008 Can anyone tell me how to use wild chars in str_ireplace. I am trying to edit anything that follows the pattern: [NUMBER]F. I really just want to remove some Fahrenheit temperatures from a string. Link to comment https://forums.phpfreaks.com/topic/124380-solved-wildchars-in-str_ireplace/ Share on other sites More sharing options...
genericnumber1 Posted September 15, 2008 Share Posted September 15, 2008 You would want to use regex... possibly preg_replace() [0-9]+F would be a pattern you might consider. Link to comment https://forums.phpfreaks.com/topic/124380-solved-wildchars-in-str_ireplace/#findComment-642400 Share on other sites More sharing options...
DarkWater Posted September 16, 2008 Share Posted September 16, 2008 <?php $string = "Today's temperature will be 95F...lol."; $string = preg_replace('/\b[0-9]+F\b/i', '', $string); echo $string; ?> Link to comment https://forums.phpfreaks.com/topic/124380-solved-wildchars-in-str_ireplace/#findComment-642433 Share on other sites More sharing options...
cgimusic Posted September 16, 2008 Author Share Posted September 16, 2008 Thanks. It works great. Link to comment https://forums.phpfreaks.com/topic/124380-solved-wildchars-in-str_ireplace/#findComment-642608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.