> [!column|flex no-title] >> [!menu-dark-red|ttl-c] [[Obsidian TTRPG Tutorials]] / [[Plugin Tutorials]] / [[RegEx]] / [[Regex Pipeline - Convert to Statblock]] > [!column|4 no-title] >> [!menu-green-1|ttl-c] [[Getting Started]] > >> [!menu-green-2|ttl-c] [[Plugin Tutorials]] > >> [!menu-green-3|ttl-c] [[Community Supported Games]] > >> [!menu-green-4|ttl-c] [[Obsidian TTRPG Tutorials/Templates/Templates\|Templates]] > [!column|3 no-title] >> [!patreon|ttl-c] [Patreon](https://www.patreon.com/JPlunkett) ([Starter Vault](https://www.patreon.com/posts/obsidian-patreon-96801399)) > >> [!discord|ttl-c] [Obsidian TTRPG Community Discord](https://discord.gg/CdM9UCJdwU) > >> [!discord|ttl-c] [Obsidian Official Discord](https://discord.gg/8AF29UBUCa) **Usage:** You can type the name of a monster > highlight the name > right click and select > Regex Pipeline: Convert to Statblock. It will wrap the name of the monster in the syntax required to display the monster statblock using the [Fantasy Statblocks Plugin](obsidian://show-plugin?id=obsidian-5e-statblocks). ##### Regex Pattern ```` "([\w \(\)]+)" -> "```statblock monster: $1 ```" ```` ##### How Does It Work? Basically, you can write the name of a monster in your notes. Lets say `Goblin`. Now you can right click and trigger the plugin event with `Regex Pipeline: Convert to Statblock`. Goblin will then be replaced with the following text. ```` ```statblock monster: Goblin ``` ```` Lets break the Regex pattern down. | Regex Pattern | Highlighted Explanation | | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `(`\[\w \(\)\]+`)` | Everything between the brackets is saved to a variable allowing us to use that information later. You can reference this later with a `$1`. | | (`\[`\w \(\)\]+) | This allows the pattern to search for `[`. Note the `\` in front of it. Regex uses `[` as part of the code for it's queries. Thus we need to escape the character which tells Regex that we instead want to search for the character `[` and not use it as part of a query. | | (\[`\w` \(\)\]+) | This is shorthand (a shortcut) that matches `A-Za-z0-9_`. [Learn More](https://www.regular-expressions.info/shorthand.html) | | (\[\w` `\(\)\]+) | There is a space here, this allows the pattern to includes spaces. | | (\[\w `\(`\)\]+) | This allows the pattern to search for `(`. Note the `\` in front of it. Regex uses `(` as part of the code for it's queries. Thus we need to escape the character which tells Regex that we instead want to search for the character `(` and not use it as part of a query. | | (\[\w \(`\)`\]+) | Exactly the same as above except now we are searching for `)`. Note the `\`. This character also needs to be escaped. | | (\[\w \(\)`\]`+) | Exactly the same as above except now we are searching for `]`. Note the `\`. This character also needs to be escaped. | | (\[\w \(\)\]`+`) | Without the `+`, the query will only find a single character that matches the pattern. The `+` tells it to reuse the pattern as long as the pattern is found. Basically this allows it to find whole words or paragraphs. | | `->` | This is part of the Regex Pipeline plugin. The plugin `Finds` text above this using the pattern we define and `Replaces` the found text with the text provided below the `->`. | | "\`\`\`statblock | This will replace the found pattern with this text. | | monster: $1 | This will replace the found pattern with this text. However the `$1` is converted to match the text found using the pattern above. | | \`\`\`" | This will replace the found pattern with this text. |