📜  正则表达式起始行 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:10.882000             🧑  作者: Mango

代码示例1
// Match from the start of the line
^
//example:
let str = "HELLO hello world"
let reg = /hello/g //g option: doesn't stop at first match
str.match(reg) // Array(2)["HELLO", "hello"]
reg = /^hello/g //match hello at the start of the string
str.match(reg) // Array(1)["HELLO"]