initial
This commit is contained in:
commit
74ae93a96e
1 changed files with 94691 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
regular expressions
|
||||
|
||||
- dot character in regex dont include newline character so use this `[\s\S]` instead of `.`.
|
||||
eg: `const questionreg = /\.gpt\s+([\s\S]*)/;`
|
||||
- variables in regex
|
||||
```js
|
||||
// variable == 'REGEX'
|
||||
|
||||
// to escape special characters like +,.,etc in variable string
|
||||
function escapeRegExp(string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
|
||||
const variable = <VALUE>
|
||||
|
||||
let re = new RegExp(String.raw`\s${variable}\s`, "g");
|
||||
```
|
||||
- word boundary
|
||||
to search by word `/\bword\b/` instead of `/word/`
|
||||
Loading…
Reference in a new issue