Difference between revisions of "Regex Snippets"
From Roll20 Wiki
Andreas J. (Talk | contribs) (Created page with "{{revdate}} Roll20-related {{wiki|Regular_expression|Regex}} snippets, that could be useful in [[|Macro Guide|macro generation]], Character Sheet Development- and [[API De...") |
Andreas J. (Talk | contribs) m |
||
(One intermediate revision by one user not shown) | |||
Line 1: | Line 1: | ||
− | {{revdate}} | + | {{revdate}}{{stub}} |
− | Roll20-related {{wiki|Regular_expression|Regex}} snippets, that could be useful in [[ | + | Roll20-related {{wiki|Regular_expression|Regex}} snippets, that could be useful in [[Macro Guide|macro generation]], [[Character Sheet Development]]- and [[API Development]], along with creating external tools. |
Depending on where you use the snippets, you might need to escape | Depending on where you use the snippets, you might need to escape | ||
Line 7: | Line 7: | ||
* <code>/(\/roll|\/r|\/em|\/w|\/whisper|\/gmroll|\/gr|\/ooc|\/fx|\/desc|\/as|\/emas|\/talktomyself|(\!|\#)[a-z\\-]*)/g</code> - target any of the {{Text Chat}} commands, or any API command keywords (e.g.{{c|!token-mod}}) - [https://github.com/Anduh/rmacro/blob/a0ca976d20d4510d673346603e5164924b5cba85/syntaxes/rmacro.tmLanguage.json#L53 source] | * <code>/(\/roll|\/r|\/em|\/w|\/whisper|\/gmroll|\/gr|\/ooc|\/fx|\/desc|\/as|\/emas|\/talktomyself|(\!|\#)[a-z\\-]*)/g</code> - target any of the {{Text Chat}} commands, or any API command keywords (e.g.{{c|!token-mod}}) - [https://github.com/Anduh/rmacro/blob/a0ca976d20d4510d673346603e5164924b5cba85/syntaxes/rmacro.tmLanguage.json#L53 source] | ||
− | * <code>/&(?:[a-z\d]+|#\d+|#x[a-f\d]+);/g</code> target any [[HTML Entities|HTML entity]] - [regexr.com/3eauj source] | + | * <code>/&(?:[a-z\d]+|#\d+|#x[a-f\d]+);/g</code> target any [[HTML Entities|HTML entity]] - [https://regexr.com/3eauj source] |
TODO | TODO |
Latest revision as of 09:00, 5 June 2022
Page Updated: 2022-06-05 |
This article is a stub. |
Roll20-related Regex snippets, that could be useful in macro generation, Character Sheet Development- and API Development, along with creating external tools.
Depending on where you use the snippets, you might need to escape
Contents |
[edit] Snippets
-
/(\/roll|\/r|\/em|\/w|\/whisper|\/gmroll|\/gr|\/ooc|\/fx|\/desc|\/as|\/emas|\/talktomyself|(\!|\#)[a-z\\-]*)/g
- target any of the q Text Chat commands, or any API command keywords (e.g.!token-mod
) - source -
/&(?:[a-z\d]+|#\d+|#x[a-f\d]+);/g
target any HTML entity - source
TODO
- snippets to detect character_id, token_id, RowID, attibutes
- improve above examples
[edit] Use Examples
- Supers RED char sheet -- uses regex in Custom Roll Parsing-sheetworkers to parse Repeating Section attributes and sanitize attributes containing text intended to display with the final result
- 1.10/ChatSetAttr.js -- ChatSetAttr API uses regex to parse and replace user commands with regex.
- Roll20 Macros -- VS Code extension to show syntax highlight for roll20 macros. Uses regex to identify snippets to highlight.
[edit] Related Pages
- VS Code
- Custom Roll Parsing - using regex is common for parsing roll results
[edit] Links
- https://regexr.com/ - has a search for community snippets
- https://regexper.com/ - visualize regex snippets
- https://regex101.com/