Does anyone know a code in command prompt that deletes a word in notepad if it is smaller and larger than 7 characters?
Thanks :)
Printable View
Does anyone know a code in command prompt that deletes a word in notepad if it is smaller and larger than 7 characters?
Thanks :)
Hmm nope but I can write it in php lol
You enter text and it will parse it and remove all words that fit certain conditions.
You can't do this in the command prompt.
Best option is to use C, but PHP will do the job too. You generally need to write a code that will how many alpha (a-z) characters exist. When it finds a space or a period, it should reset the counter. And when the counter is 7 or higher, you can just replace the word by nothing.
Okay I typed that up inside this window, untested and what not.PHP Code:<?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." ";
}
*/
?>
Might work might not lol
That doesn't cover symbols, numbers etc. You would need to add more sets (ie 0-9) to it to get every word.