Spring 2019 。 Ric Huang
npm install -g bottender
bottender init
Change the code in "src/index.js"
Understand "regular expression"
Learn/Use "Natural Language Understanding (NLU)" APIs
. : matches any single character except \n
* : matches 0 or more instances of the preceding reg
exp
+ : matches 1 or more instances of the preceding reg exp
? : matches 0 or 1 of the preceding regular expression
| : matches the preceding or following reg exp
[ ] : defines a character class (e.g. [a-zA-Z])
( ) : groups enclosed regular expression into a new reg exp
"…" : matches everything within the " " literally
* a natural number: e.g. 12345
==> [1-9][0-9]*
* a word: e.g. cat
==> [a-zA-Z]+
* a C/C++ variable: e.g. _name38
==> [_a-zA-Z][_0-9a-zA-Z]*
* a (possibly) signed integer: 12345 or -12345
==> [-+]?[1-9][0-9]*
* a floating point number: 1.2345
==> [0-9]*"."[0-9]+
x|y x or y
x/y x, only if followed by y (y not removed from input)
x{m,n} m to n occurrences of x
^x x, but only at beginning of line
x$ x, but only at end of line
meta-characters (do not match themselves, because they are used in the preceding reg exps):
( ) [ ] { } < > + / , ^ * | . \ " $ ? - %
to match a meta-character, prefix with \
to match a backslash, tab or newline, use \\, \t, or \n
let re = /pattern/flags;
// or
let re = new RegExp('pattern', 'flags');
Apply a freemium account at: https://app.yoctol.ai
Help docs at: https://docs.yoctol.ai