text replacement in notepad++ examples.


21st oct 2024.
validation of corrected text of pss books as follows.

1. Once you complete.
check all short lines 

check all before 
^.{35,40}$   find next and guess ;
^.{10,35}
^.{0,10}











-----------------
replace more then 2 empty char.\s{2,} with empty








-------

formating 4 lines in single line , repeat sequence.






-----------------
https://www.mynikko.com/tools/tool_duplicateremover.html

check duplicate line once, if is good or not.
------
checking ocr , shifting char

^.{1,20}$  finding char length from 1 to 20 in a line;

^.{20,30}$ string length from 20 to 30 in a line.

--------------


merge two page breakers.
(.*[^\.?])\n\n(.*)  with \1\n\2
(.*[^\.?])\n\n\n(.*)  with \1\n\2




----------
^(.*[^?!\)\.])\r\n\r\n(.*)\r\n

find line separated 





Page.*
^\d+\n
^\d+\n$
----

20 Text Replacement Examples with Regular Expressions in Notepad++
Understanding the Basics
Before we dive into examples, let's quickly recap some essential regular expression (regex) concepts:
 * Metacharacters: Special characters with specific meanings (e.g., . matches any character, * matches zero or more repetitions).
 * Quantifiers: Specify the number of occurrences of a preceding element (e.g., + one or more, ? zero or one).
 * Character Classes: Define sets of characters (e.g., \d for digits, \w for word characters).
 * Anchors: Match specific positions within a text (e.g., ^ start of line, $ end of line).
To perform a text replacement in Notepad++:
 * Open the "Replace" dialog (Ctrl+H).
 * Enable the "Regular expression" option.
 * Enter your regex pattern in the "Find what" field.
 * Enter the replacement text in the "Replace with" field.
 * Click "Replace All" or "Replace" to apply the changes.
Example Categories
1. Removing Extra Spaces
 * Find: \s+
 * Replace: (single space)
2. Removing Leading and Trailing Spaces
 * Find: ^\s+|\s+$
 * Replace: Empty
3. Converting Text to Uppercase
 * Find: \w+
 * Replace: \U$0
4. Converting Text to Lowercase
 * Find: \w+
 * Replace: \L$0
5. Removing Duplicate Lines
 * Find: ^(.*)\r\n\1$
 * Replace: Empty
6. Adding a Prefix or Suffix
 * Find: ^(.*)$
 * Replace: prefix\1suffix
7. Replacing Specific Text with Another
 * Find: old_text
 * Replace: new_text
8. Extracting Numbers
 * Find: \D+(\d+)\D+
 * Replace: $1
9. Removing Comments from Code
 * Find: //.*$ or #.*$
 * Replace: Empty
10. Replacing HTML Tags
 * Find: <[^>]*>
 * Replace: Empty
11. Formatting Phone Numbers
 * Find: (\d{3})(\d{3})(\d{4})
 * Replace: ($1) $2-$3
12. Extracting Email Addresses
 * Find: \S+@\S+\.\S+
 * Replace: $0 (to simply highlight)
13. Replacing Multiple Spaces with Tabs
 * Find: {2,}
 * Replace: \t
14. Removing Empty Lines
 * Find: ^\s*\n
 * Replace: Empty
15. Adding Line Numbers
 * Find: ^(.*)$
 * Replace: \1. (replace . with desired line number format)
16. Splitting Lines at a Specific Character
 * Find: (.).*
 * Replace: $1\n
17. Combining Lines
 * Find: \n
 * Replace:  
18. Changing Case of First Letter in Each Word
 * Find: \b(\w)
 * Replace: \U$1
19. Adding Quotes Around Text
 * Find: (\w+)
 * Replace: "$1"
20. Removing Non-alphanumeric Characters
 * Find: [^a-zA-Z0-9]
 * Replace: Empty
Remember:
 * Test your regex patterns carefully before applying them to your entire document.
 * Use online regex testers to experiment and visualize matches.
 * Consider using capturing groups (()) to extract specific parts of the matched text.
Additional Tips:
 * Explore other metacharacters and quantifiers for more complex patterns.
 * Utilize lookahead and lookbehind assertions for advanced matching.
 * Consider using named capturing groups for better readability.
By mastering these examples and understanding the underlying principles, you can efficiently manipulate text using regular expressions in Notepad++.
Would you like to explore a specific category in more detail or do you have a particular text manipulation task in mind?

-------
Next 30 Frequently Used Text Replacement Examples with Regular Expressions in Notepad++
More Complex Text Manipulations
21. Extracting Data Between Specific Delimiters
 * Find: (?<=delimiter1)(.*)(?=delimiter2)
   * Replace with $1 to extract the data
   * Example: (?<=\[)(.*)(?=\]) to extract text between square brackets
22. Replacing Specific Occurrences of a Word
 * Find: \bword\b(?!.*\bword\b)
   * Replace with new_word to replace the first occurrence
 * Find: \bword\b(?!.*\bword\b)
   * Replace with new_word to replace the second occurrence, and so on.
23. Matching and Replacing Overlapping Text
 * Find: (?=(word1|word2))
   * Replace with replacement to replace overlapping occurrences
24. Removing Duplicate Words Within a Line
 * Find: \b(\w+)\s+\1\b
   * Replace with $1
25. Replacing Text Based on Conditions
 * Find: (?<=condition1)text(?=condition2)
   * Replace with new_text
26. Extracting URLs from Text
 * Find: http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+
   * Replace with $0 to highlight or extract
27. Replacing Numbers with Textual Representations
 * Find: \b(\d+)\b
   * Replace with a custom function or lookup table to convert numbers to text
28. Formatting Dates
 * Find: (\d{2})/(\d{2})/(\d{4})
   * Replace with $3-$1-$2 to change format from DD/MM/YYYY to YYYY-MM-DD
29. Removing Punctuation
 * Find: [^\w\s]
   * Replace with empty string
30. Standardizing Text (e.g., removing accents)
 * Use appropriate Unicode character classes or online tools to create specific patterns
Working with Text Structures
31. Balancing Parentheses
 * Use recursive patterns or custom scripting to ensure proper matching
32. Indenting Code
 * Find: ^(.*){
   * Replace with \t$1{ to increase indentation
33. Unindenting Code
 * Find: ^\t+(.*){
   * Replace with $1{ to decrease indentation
34. Converting Text to a Table
 * Find: \n
   * Replace with | for columns and \n for rows
35. Extracting Data from Log Files
 * Use specific patterns based on log format to extract relevant information
Text Cleaning and Formatting
36. Removing Control Characters
 * Find: [\x00-\x1F\x7F]
   * Replace with empty string
37. Converting Quotes
 * Find: “ or ”
   * Replace with "
38. Correcting Spelling Errors
 * Use a spell checker or language-specific rules
39. Normalizing Whitespace
 * Find: \s+
   * Replace with a single space
40. Converting Text to HTML Entities
 * Use character references or online tools
Advanced Text Manipulation
41. Extracting Information from XML or JSON
 * Use specific patterns or dedicated tools
42. Generating Random Text
 * Use custom functions or online generators
43. Encrypting or Decrypting Text
 * Use appropriate encryption algorithms
44. Compressing or Decompressing Text
 * Use compression/decompression libraries
45. Translating Text
 * Use translation APIs or tools
Remember:
 * The effectiveness of these examples depends on the specific text data you're working with.
 * Always test your regular expressions carefully before applying them to your entire document.
 * Consider using online regex testers and debuggers to help you refine your patterns.
 * For complex tasks, explore scripting languages or dedicated text processing tools.
Would you like to focus on a specific type of text manipulation or explore a particular use case?

--------
Input/Output Examples for Regular Expressions in Notepad++
Basic Text Manipulation
 * Removing Extra Spaces:
   * Input: "This is a text with extra spaces."
   * Output: "This is a text with extra spaces."
 * Removing Leading and Trailing Spaces:
   * Input: " Some text with spaces "
   * Output: "Some text with spaces"
 * Converting Text to Uppercase:
   * Input: "hello world"
   * Output: "HELLO WORLD"
 * Converting Text to Lowercase:
   * Input: "HELLO WORLD"
   * Output: "hello world"
 * Removing Duplicate Lines:
   * Input:
     line1
line2
line2
line3

   * Output:
     line1
line2
line3

 * Adding a Prefix or Suffix:
   * Input: "example text"
   * Output: "prefixexample textsuffix"
 * Replacing Specific Text with Another:
   * Input: "This is old text"
   * Output: "This is new text"
 * Extracting Numbers:
   * Input: "There are 123 apples and 456 oranges"
   * Output: 123456
 * Removing Comments from Code:
   * Input:
     # This is a comment
x = 10 # Another comment

   * Output:
     x = 10

 * Replacing HTML Tags:
 * Input: "<p>This is some text</p>"
 * Output: "This is some text"
 * Formatting Phone Numbers:
 * Input: 1234567890
 * Output: (123) 456-7890
 * Extracting Email Addresses:
 * Input: "Contact us at [email address removed]"
 * Output: [email address removed] (highlighted or extracted)
 * Replacing Multiple Spaces with Tabs:
 * Input: "This is a text with multiple spaces"
 * Output: "This is a text with multiple spaces" (spaces replaced with tabs)
 * Removing Empty Lines:
 * Input:
   line1

line2

 * Output:
   line1
line2

 * Adding Line Numbers:
 * Input:
   line1
line2
line3

 * Output:
   1. line1
2. line2
3. line3

 * Splitting Lines at a Specific Character:
 * Input: "word1.word2.word3"
 * Output:
   word1
word2
word3

 * Combining Lines:
 * Input:
   line1
line2

 * Output: "line1 line2"
 * Changing Case of First Letter in Each Word:
 * Input: "hello world"
 * Output: "Hello World"
 * Adding Quotes Around Text:
 * Input: hello world
 * Output: "hello" "world"
 * Removing Non-alphanumeric Characters:
 * Input: "This is a text with !@#$%^&*()"
 * Output: "This is a text with"
More Complex Text Manipulations
Note: Providing comprehensive input/output examples for all 45 cases would be extremely lengthy. I'll provide examples for a few more complex cases to illustrate the concept.
 * Extracting Data Between Specific Delimiters:
 * Input: "[data1] some text [data2]"
 * Output: data1
 * Replacing Specific Occurrences of a Word:
 * Input: "word word word"
 * Output: "new_word word word" (replacing first occurrence)
 * Matching and Replacing Overlapping Text:
 * Input: "word1word2word1"
 * Output: "replacementreplacementreplacement"
 * Removing Duplicate Words Within a Line:
 * Input: "the the quick brown fox fox"
 * Output: "the quick brown fox"
 * Replacing Text Based on Conditions:
 * Input: "before condition1 text condition2 after"
 * Output: "before condition1 new_text condition2 after"
 * Extracting URLs from Text:
 * Input: "Visit our website at https://www.example.com"
 * Output: https://www.example.com (highlighted or extracted)
 * Replacing Numbers with Textual Representations:
 * Input: "There are 12 apples"
 * Output: "There are twelve apples"
 * Formatting Dates:
 * Input: 02/15/2024
 * Output: 2024-02-15
 * Removing Punctuation:
 * Input: "This, is. a? text!"
 * Output: "This is a text"
 * Standardizing Text (e.g., removing accents):
 * Input: "résumé"
 * Output: "resume" (depending on specific implementation)
I can provide more examples for specific cases if you need them.
Would you like to focus on a specific category or have a particular text manipulation task in mind?


_-----------
Continuing with Text Replacement Examples
Working with Text Structures
31. Balancing Parentheses:
 * Input: "( ( ) ) ( )"
 * Output: "( ( ) ) ( )" (if balanced) or an error message (if unbalanced)
32. Indenting Code:
 * Input:
   function myFunction() {
code;
}

 * Output:
   function myFunction() {
    code;
}

33. Unindenting Code:
 * Input:
       function myFunction() {
        code;
    }

 * Output:
   function myFunction() {
code;
}

34. Converting Text to a Table:
 * Input:
   column1 data1
column2 data2
column3 data3

 * Output:
   | column1 | data1 |
| column2 | data2 |
| column3 | data3 |

35. Extracting Data from Log Files:
 * Input:
   [2024-08-04 12:34:56] INFO: Process completed successfully

 * Output:
   Date: 2024-08-04
Time: 12:34:56
Level: INFO
Message: Process completed successfully

   (Specific extraction depends on log format)
Text Cleaning and Formatting
36. Removing Control Characters:
 * Input: "This text contains ^M characters" (where ^M is a control character)
 * Output: "This text contains characters"
37. Converting Quotes:
 * Input: “This text uses curly quotes”
 * Output: "This text uses straight quotes"
38. Correcting Spelling Errors:
 * Input: "There is a speling error here"
 * Output: "There is a spelling error here" (assuming a spell checker is used)
39. Normalizing Whitespace:
 * Input: "This is a text with extra spaces"
 * Output: "This is a text with extra spaces"
40. Converting Text to HTML Entities:
 * Input: "<"
 * Output: "<"
Advanced Text Manipulation
41. Extracting Information from XML or JSON:
 * Input:
   <book>
    <title>Example Book</title>
    <author>John Doe</author>
</book>

 * Output:
   Title: Example Book
Author: John Doe

42. Generating Random Text:
 * Input: (no specific input)
 * Output: (randomly generated text, e.g., "kj3h8sdfo")
43. Encrypting or Decrypting Text:
 * Input: "secret message"
 * Output: "encrypted text" (depends on encryption method)
44. Compressing or Decompressing Text:
 * Input: (compressed text)
 * Output: (decompressed text)
45. Translating Text:
 * Input: "Hello, world!"
 * Output: "Hola, mundo!" (assuming translation to Spanish)
Note: These examples are simplified for demonstration purposes. Actual implementation might require more complex regular expressions and potentially external libraries or tools.
Would you like to focus on any specific area or do you have a particular text manipulation task in mind?


----
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class RemoveExtraSpaces {
    public static void main(String[] args) {
        String inputFile = "input.txt";
        String outputFile = "output.txt";

        try (BufferedReader reader = new BufferedReader(new FileReader(inputFile));
             FileWriter writer = new FileWriter(outputFile)) {

            String line;
            while ((line = reader.readLine()) != null) {
                String modifiedLine = line.replaceAll("\\s+", " "); // Replace multiple spaces with single space
                writer.write(modifiedLine + System.lineSeparator());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
-------


Popular posts from this blog

pss book : శ్రీకృష్ణుడు దేవుడా, భగవంతుడా completed , second review needed. 26th April 2024

pss book: గురు ప్రార్థనామంజరి . completed 21st july 2024

pss book: కధల జ్ఞానము read review pending. 25th june 2024