Introducing microregex - A highly Curated Catalog of RegEx Patterns

Search for a command to run...

No comments yet. Be the first to comment.
Authentication is a fundamental aspect of modern web and mobile applications. It ensures that users can securely access an app while protecting their data. Firebase, a platform developed by Google, offers a simple and efficient way to add authenticat...

Hello there! My name is Shivam, and today, I will show you how to create this beautiful horizontal scrolling parallax effect with HTML, CSS, and JavaScript. Wouldn't this look stunning on your blog or portfolio site? To achieve this effect, we will ...

Dealing with fonts can get quite overwhelming. For quite some time, I was searching for a way to self-host google fonts because the google fonts API's network request increased the render-blocking time more than I expected. I stumbled upon fontsource...

Our favorite month is here! And we have some amazing activities planned for our community π€© Yes, you are right. We are talking about Hacktoberfest! In this blog, we want to cover various ways you can participate in Hacktoberfest through the ReactPla...

The second edition of ReactPlay Hackathon is here!

Regular expressions are an important aspect of software development. Owing to being a powerful and complex language, they can be used to search and replace text, validate input, extract data from structured documents, and more. Remembering all the different regex patterns can be a difficult task. Having an app that will provide you with a list of common regex patterns and their use cases will definitely help.
microregex is an open source and highly curated catalog of regular expression patterns. It offers programmers RegEx snippets that can be quickly exported into a variety of programming languages and distributed around teams. Whether you are building an app or a website, microregex is the right place for you.
While coding, I found myself spending a lot more time merely scanning the regex for various sorts of validation rather than needing to fast search and locate one that fits my needs. Most developers jump through numerous hoops of Stack Overflow responses or an article discussing a specific regex snippet to get the one regex pattern that they require. It seems like a lengthy procedure. A friend of mine who experienced the same discomfort joined me in developing a tool that will make finding and copying regex patterns simpler.
Try out microregex by clicking on the link below:
https://microregex.netlify.app/

Search and copy common regex patterns
Syntax highlighting
Ability to copy code directly for multiple programming languages
Ability to filter search based on tags
Formatted code for a specific language
Backend: Nhost [https://nhost.io/]
Frontend: React.js [https://reactjs.org/], Chakra-UI [https://chakra-ui.com/]
Database: PostgreSQL + GraphQL [https://hasura.io/]
Deployment: Netlify [https://www.netlify.com/]
microregex/
ββ assets/
ββ public/
β ββ favicon.ico
β ββ index.html
β ββ robots.txt
ββ src/
β ββ components/
β β ββ card.tsx
β β ββ navbar.tsx
β ββ graphql/
β β ββ queries.ts
β ββ pages/
β β ββ home.tsx
β ββ utils/
β β ββ copytest.ts
β β ββ tags.ts
β ββ index.css
β ββ index.js
ββ .gitignore
ββ package.json
ββ README.md
We follow simplicity as we explore through the folder structure where files are grouped together based on the usage.
pages β are the parent components that can be hyperlinked
components β mini components that could be re-used
graphql β all our queries going out to
utils β all of our utility code that could be reused
For storing data, we have used Nhost database, which uses Hasura Postgres DB. Nhost encapsulates and makes it easier for you to use, access and navigate the database and storage modules provided by Hasura.
We used two different graphql queries for searching
query {
patterns {
name
description
tags
content
preview
}
}
query getPatternsLike($name: String){
patterns(where: {name: {_ilike: $name}}) {
name
description
tags
preview
content
}
}
The primary challenge which we faced was that after querying the jsonb data using contains operator as mentioned here we would get an error as below

Nhost wasn't allowing us to query multiple strings in an array of strings.
Old GraphQL Query:
query getPatterns($tags: jsonb) {
patterns(
where: {
_and: [{ name: { _ilike: "%%" } }, { tags: { _contains: $tags} }]
}
){
name
description
tags
}
}
Old Variables:
{
"tags": ["auth", "finance"]
}
As you can see, if one or more elements are included in variables, as shown in the above query and variables snippet, it gives the same error as mentioned in the above paragraph.
New GraphQL Query:
query getPatterns($where: patterns_bool_exp) {
patterns(where: $where) {
name
description
tags
content
preview
}
}
New Variables:
{
"where": {
"_and": [
{
"name": {
"_ilike": "%%"
}
},
{
"_or": [
{
"tags": {
"_contains": "finance"
}
}
]
}
]
}
}
So instead of comparing the objects, we used patterns_bool_exp. It is a boolean expression to filter out rows from a table, 'patterns' in our case, and all the fields are combined with a logical 'AND'.
If you're looking to host your Postgres database for free, you should definitely check out Nhost. It has a lot of features similar to Firebase with the ability to query data using GraphQL and use Hasura for all development services.
Checkout the docs here: [https://docs.nhost.io/]
Implemented a debounced search and filtering where limited requests are made avoiding unnecessary calls to our GraphQL endpoints
Responsiveness
We used useMediaQuery hook & inline styling to handle responsiveness at certain breakpoints.
Take advantage of color mode offered by chakra-ui to add dark mode support
Visualize regex with examples
Language export script that will optimize data entry
Revisit search and make it more user-friendly
Hacktoberfest is a great initiative in my opinion because it encourages more contributions, more developer engagement and in turn a rapid growth of countless open source projects. If you are a developer interested in contributing to an open source project,
App: https://microregex.netlify.app/
GitHub repo: https://github.com/Maddoxx88/microregex
We would like to thank Nhost and React-Play for hosting Hack-R-Play. Special thanks to the members of React-Play discord server for providing such a good support.