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
Markdown
# π 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')
```