LogoLogo
Packmind CloudChangelogGet supportJoin Slack
  • 👋Welcome!
  • 🪐Manage spaces
  • 🔐Security and data
  • 🐞Troubleshooting guides
  • 🚀First steps
    • Enable and configure AI
    • Connect your Git platform
  • 📥Capture your coding practices
    • How to create coding practices
    • Review practices in the Inbox
  • 🔍Enforce practices in your code
    • Setup practices detection with the AI Agent
    • Packmind CLI
      • Run with NPM
      • Run with Docker
      • SonarQube Integration
      • Run in Gitlab CI
  • Coding Assistants Integration
  • 👩‍💻Plugins & Integrations
    • IDE Plugins
      • 🚀Packmind's IDE plugins use cases
      • Visual Studio Code
      • Visual Studio
      • JetBrains IDEs
      • Eclipse
      • Xcode
      • Packmind Tech Coach
    • 🔔Get notifications
  • 📖Best practices management
    • Manage your practices
      • Import, copy and export practices
      • Use categories to organize your practices
      • Manage duplications of practices
      • Move all practices from a space to another space
      • Styling with Markdown
      • Multi-file examples on coding practices
    • 📰Scheduler to push practices
  • ↔️API Reference
    • Authentication
    • Documentation
  • ⚙️Account & Settings
    • 👩‍💼Manage users
    • 💵Subscription and Billing
    • 🔓Single Sign-On (SSO) in Packmind
      • Enable SSO for Packmind Cloud
      • Enable SSO for Packmind Self-Hosted
  • 🏠On-Premise version
    • Release notes - Self-Hosted versions
    • Install the Self-Hosted version
      • Migrate from a legacy setup (Mongo 2.x)
    • Connect a SMTP server
    • Authentication
      • Authentication with OpenLDAP
      • Authentication by SSO
      • Authentication with Active Directory
Powered by GitBook
On this page
  • Add a regular expression
  • Suggestion with AI
  • Specify file extensions
  • Order regular expressions

Was this helpful?

  1. Enforce practices in your code
  2. Configure how practices are detected

Use Regular Expressions

Last updated 6 months ago

Was this helpful?

Please be aware that Packmind supports the ECMAScript flavor for regular expressions

Add a regular expression

In Packmind, select the practice on which you want to add a regular expression and click on the Configure Automatic Suggestions menu (bottom right of the modal).

Then, click on "+Add a regex configuration":

This will open this menu, where you have two main inputs in the form:

  • an input to specify your regular expression

  • an editor to test your expression against a source code

A switch button allows you to configure this regular expression for :

  • "positive": create an expression that identifies if a best practice is followed

  • "negative": create an expression that identifies if a best practice is not followed

If you have some existing examples in your best practice documentation, you'll find them listed below the editor. Just click on one of them to fill the editor with an example and test your regular expression against it.

Once you're satisfied with your regular expression, validate the operation by clicking the Add button.

Keep in mind you can add multiple regular expressions for a single practice!

Suggestion with AI

This feature automatically generates a regular expression tailored to your practice, distinguished by an "AI" icon and a distinctive purple border. The accuracy and effectiveness of the generated suggestion improve with the number of examples you associate with your practice. It's important to note that the generated suggestions are consistently designed to identify negative matches (cases where your coding practice is not followed).

Specify file extensions

If you want to restrict the search of regular expressions to some specific file name (not the full path) or extensions, you can specify them on the right side of the regex edition:

Don't forget to click on the "+" button for each pattern you want to include.

Order regular expressions

If you've configured several regular expressions, both for positive and negative detection, you can define a priority order among them.

You can use the arrows on the left side to change the expression priorities. The algorithm will test each expression by order, and once one matches, it stops the execution. Thus, you won't get both positive and negative results since the first matching ends the search.

🔍
This is an example of AI generated regular expression for the practice "Avoid using type any" for Typescript files