Regex for messages

trying to have a message read aloud when someone says a keyword like hi, hello, i want it to only check the first word for the keyword Regex: /\b(hi|suh|sup|hello|hey|greetings|good morning|good afternoon|good evening)\b/i this reads the message weither the hi is the first, last or middle word
6 Replies
Marc
Marc15mo ago
Try /^(hi|suh|sup|hello|hey|greetings|good morning|good afternoon|good evening)\b/i
Marc
Marc15mo ago
You can use https://regexr.com to test
RegExr
RegExr: Learn, Build, & Test RegEx
RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp).
SkullGamingHQ
SkullGamingHQOP15mo ago
yea i was using https://regex101.com to test
regex101
regex101: build, test, and debug regex
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.
Marc
Marc15mo ago
Yeah that works too. Just make sure you use the JavaScript flavor
SkullGamingHQ
SkullGamingHQOP15mo ago
OHHH thats why it didnt work lol i didnt even see that it was set to, PHP instead of javascript lol
Marc
Marc15mo ago
Hehe yeah that gets me too

Did you find this page helpful?