Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1183.Advanced search and replace -- How to limit each line to specified length without breaking word?

User: Aaron -- 2014-03-09          << 1182  1184 >>
Hits: 3329
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
How to  limit each line to specified number of characters and not break word with following options: 
 
1. Keep 1-40 characters of each line and delete rest of line 
 
2. Keep characters from 41 to end of line and delete characters 1-40
Input Sample:
More than 4.3 million homes collapsed or sustained damage, according to the Embassy in Washington. 
But casualty figures from various cities indicate a higher number of dead.
Output Sample:
Output Sample 1: (Keep 1-40 characters of each line and delete rest of line) 
 
More than 4.3 million homes collapsed or   
 
But casualty figures from various cities   
 
---------------------------------------------------- 
 
Output Sample 2: (Keep characters from 41 to end of line and delete characters 1-40) 
 
sustained damage, according to the Embassy in Washington. 
 
indicate a higher number of dead.
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
Keep 1-40 characters: 
1. ctrl-o open text file 
2. ctrl-h open 'replace' dialogue 
* set 'replace unit' to 'Chars' 
* set 'replace scope' to 'Line' 
* set 'search for pattern' to: 
 
* set 'replace with pattern' to: 
 
* uncheck 'print unmatched unit' option 
3. click 'replace', done. 
 
Remove 1-40 characters: 
Same as above, except that in step 2: 
* set 'replace with pattern' to 'blank' 
* check 'print unmatched unit' option 
 
If you want to do it in "batch runner" window. 
Keep 1-40 characters: 
 
1. open "Tools->Batch Runner" menu 
2. drag multiple files to batch runner window 
3. click "Fast Replace" button 
4. click "add" to add new rules: 
* set "search" to: 
 
* set 'replace' to: 
 
* click ok 
5. check option of "reg exp" and "extract", uncheck option of "cross line" 
6. click "start", done. 
 
Remove 1-40 characters: 
Same as above, except that in step 5: 
* set 'replace' to blank 
* uncheck 'extract' option

Screenshot 1:  Replace_Window


Screenshot 2:  Fast_Replace_Window


Similar Examples:
How to add hard returns to limit line length to 40, but without breaking word? (66%)
How to wrap text by adding return but without breaking words? (59%)
How to replace the specified text with increasing HEX strings? (56%)
How to sort all lines of text by specified keyword? (56%)
How to change each line of data to the specified format? (53%)
How to rip out all but line 1 and specified text? (53%)
How to search and replace text for specified occurrences with reg exp? (53%)
How to change columns in each line to specified order in text file? (53%)

Check Demo of Advanced search and replace
Keywords:
without break  keep character  except  delete characters  delete character  break  delete char  length  number of characters  without  limit line length  batch to replace word with 5 characters  add new line break  delete characters from each line text file  delete except  delete number each line  delete end characters  delete characters end of line