Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joaodos3v/682e5be26d0b129554d272d1b56a57fb to your computer and use it in GitHub Desktop.
Save joaodos3v/682e5be26d0b129554d272d1b56a57fb to your computer and use it in GitHub Desktop.
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|[().,\-:;@#$%^&*\[\]"'+–/\/®°⁰!?{}|~]| )+?(?=())`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment