<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Text Processing on AI VOID</title><link>https://ai-blog.noorshomelab.dev/tags/text-processing/</link><description>Recent content in Text Processing on AI VOID</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 30 Dec 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://ai-blog.noorshomelab.dev/tags/text-processing/index.xml" rel="self" type="application/rss+xml"/><item><title>Sed Streamline - Linux Text Crafting Essentials</title><link>https://ai-blog.noorshomelab.dev/cut-the-chase/sed-streamline/</link><pubDate>Tue, 30 Dec 2025 00:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/cut-the-chase/sed-streamline/</guid><description>&lt;h1 id="sed-streamline---linux-text-crafting-essentials"&gt;Sed Streamline - Linux Text Crafting Essentials&lt;/h1&gt;
&lt;p&gt;GNU sed 4.9 (stable as of 2025-12-30). A stream editor for filtering and transforming text.&lt;/p&gt;
&lt;h2 id="core-syntax"&gt;Core Syntax&lt;/h2&gt;
&lt;p&gt;The fundamental operation in &lt;code&gt;sed&lt;/code&gt; is substitution. This block demonstrates basic text replacement.&lt;/p&gt;
&lt;div class="highlight"&gt;
&lt;pre class="language-bash line-numbers" data-start="1" tabindex="0"&gt;&lt;code class="language-bash" data-lang="bash"&gt;# Example file content:
# line 1: This is a test.
# line 2: Another test line.
# line 3: Test complete.
# Basic substitution: &amp;#39;s/regexp/replacement/flags&amp;#39;
echo &amp;#34;This is a test.&amp;#34; | sed &amp;#39;s/test/example/&amp;#39; # Replaces &amp;#39;test&amp;#39; with &amp;#39;example&amp;#39; on the first match per line.
# Output: This is a example.
# Global substitution (g flag): replaces all occurrences on a line.
echo &amp;#34;test test test&amp;#34; | sed &amp;#39;s/test/ok/g&amp;#39; # Replaces all &amp;#39;test&amp;#39; with &amp;#39;ok&amp;#39;.
# Output: ok ok ok
# Case-insensitive substitution (I flag - GNU sed extension).
echo &amp;#34;This Is A Test.&amp;#34; | sed &amp;#39;s/test/success/I&amp;#39; # Replaces &amp;#39;Test&amp;#39; with &amp;#39;success&amp;#39;, ignoring case.
# Output: This Is A success.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id="essential-patterns"&gt;Essential Patterns&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;sed&lt;/code&gt; excels at filtering and deleting lines based on patterns or line numbers.&lt;/p&gt;</description></item><item><title>Pattern Power: Regex Fast-Track - JavaScript &amp;amp; Python Essentials</title><link>https://ai-blog.noorshomelab.dev/cut-the-chase/regex-fast-track/</link><pubDate>Sat, 27 Dec 2025 00:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/cut-the-chase/regex-fast-track/</guid><description>&lt;h1 id="pattern-power-regex-fast-track"&gt;Pattern Power: Regex Fast-Track&lt;/h1&gt;
&lt;p&gt;Regular Expressions (Regex) for text pattern matching. Current versions: Python 3.12, JavaScript (ECMAScript 2024/ES15).&lt;/p&gt;
&lt;h2 id="core-syntax"&gt;Core Syntax&lt;/h2&gt;
&lt;p&gt;Regex literals (JS) or compiled patterns (Python) define the search pattern. Flags modify behavior.&lt;/p&gt;
&lt;div class="highlight"&gt;
&lt;pre class="language-javascript line-numbers" data-start="1" tabindex="0"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;// JavaScript: Regex literal (preferred for static patterns)
const reLiteral = /abc/i; // Matches &amp;#34;abc&amp;#34; case-insensitively
// JavaScript: RegExp constructor (for dynamic patterns from strings)
const patternString = &amp;#34;xyz&amp;#34;;
const reConstructor = new RegExp(patternString, &amp;#39;g&amp;#39;); // Matches &amp;#34;xyz&amp;#34; globally
// Test method returns boolean
console.log(reLiteral.test(&amp;#34;ABC&amp;#34;)); // true
console.log(reConstructor.test(&amp;#34;0xyz1xyz2&amp;#34;)); // true&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;
&lt;pre class="language-python line-numbers" data-start="1" tabindex="0"&gt;&lt;code class="language-python" data-lang="python"&gt;import re
# Python: Compile a regex pattern (preferred for repeated use)
pattern_compiled = re.compile(r&amp;#34;abc&amp;#34;, re.IGNORECASE) # Matches &amp;#34;abc&amp;#34; case-insensitively
# Python: Direct function call (for one-off uses)
match_obj = re.search(r&amp;#34;xyz&amp;#34;, &amp;#34;0xyz1xyz2&amp;#34;, re.M) # Searches for &amp;#34;xyz&amp;#34; in the string
# Match object evaluates to True if a match is found
print(bool(pattern_compiled.search(&amp;#34;ABC&amp;#34;))) # True
print(bool(match_obj)) # True&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id="essential-patterns"&gt;Essential Patterns&lt;/h2&gt;
&lt;p&gt;Character classes simplify matching common types of characters. Quantifiers specify how many times a character or group must appear.&lt;/p&gt;</description></item></channel></rss>