- Joined
- Dec 29, 2005
- Messages
- 166
- Reaction score
- 1
Does anyone know a code in command prompt that deletes a word in notepad if it is smaller and larger than 7 characters?
Thanks
Thanks

<?php
function removeWords($str){
$str = htmlspecialcharacters($str);
$arr = preg_split("/\s+/",$str);
foreach($arr as $key => $val){
if(strlen($val) >= 7){
unset($arr[$key]);
}
}
return $arr;
}
/*
Execution:
$text = removeWords($removeWords);
foreach($arr as $key => $val){
echo $val." ";
}
*/
?>
PHP:<?php function removeWords($str) { return preg_replace('/[a-zA-Z]{7,}/', '', $str); } $text = 'Oohthiswordissoolong but this word isn\'t.'; echo removeWords($text); ?>
That doesn't cover symbols, numbers etc. You would need to add more sets (ie 0-9) to it to get every word.