UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

73 lines (47 loc) β€’ 1.32 kB
# πŸ” Regex Helpers Welcome to the **Regex Helpers** guide! ✨ This document provides a collection of **ready-to-use regex patterns** to help you **transform JavaScript code** more efficiently. It’s especially useful when **migrating from jQuery to TinyHtml**, making your workflow faster, cleaner, and less error-prone. πŸš€ πŸ‘‰ These helpers were tested only in **Visual Studio Code**, so results may vary in other editors. --- ## ⚑ Basic Function Replacements Simplify and streamline JavaScript function transformations. **πŸ”„ Replace `attr`:** ```ruby attr\(([^,]+),\s*([^)]+)\) ``` ➑️ with `setAttr`: ```ruby setAttr($1, $2) ``` --- ## πŸ› οΈ Migrating from jQuery to TinyHtml ### πŸ“₯ Match jQuery with arguments ```ruby \$\(\s*['"]<([^'"]+)>['"]\s*,\s*([\s\S]*?)\) \$\((?:\s|\n)*['"]<([^'"]+)>['"](?:\s|\n)*,(?:\s|\n)*([\s\S]*?)(?:\s|\n)*\) ``` ➑️ Replace with: ```ruby TinyHtml.createFrom('$1', $2) ``` --- ### πŸ“¦ Match jQuery without arguments ```ruby \$\(\s*['"]<([^'"]+)>['"]\s*\) \$\((?:\s|\n)*['"]<([^'"]+)>['"](?:\s|\n)*\) ``` ➑️ Replace with: ```ruby TinyHtml.createFrom('$1') ``` --- ### πŸ”Ž Match jQuery queries ```ruby \$\(\s*['"]([^'"]+)['"]\s*\) \$\((?:\s|\n)*['"]([^'"]+)['"](?:\s|\n)*\) ``` ➑️ Replace with: ```ruby TinyHtml.query('$1') ```