Skip to content

Instantly share code, notes, and snippets.

View joaodos3v's full-sized avatar
🦇
I don't know why I started using a bat as emoji

João Vitor Veronese Vieira joaodos3v

🦇
I don't know why I started using a bat as emoji
View GitHub Profile
@joaodos3v
joaodos3v / Several regex to match opening and closing pair of a specific tag.md
Last active March 10, 2020 14:05
I needed to find all ReactJS components that contained plain text as content and these regular expressions helped me.

Matches the opening and closing pair of a specific HTML tag.

<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>

Matches the opening and closing pair of a specific HTML tag that contain one or more letters and numbers and _.

<([A-Z][A-Z0-9]*)\b[^>]*>[a-zA-Z0-9_.-]+</\1>

Test

(?<=(<pre>))(\w|\d|\n|[().,\-:;@#$%^&*\[\]"'+–/\/®°⁰!?{}|~]| )+?(?=())`