Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Majeed's avatar

How to write Regex in Laravel

I want write a regex for abc-def-ghi this type of string. a string have must - sign if it'll not available then show a validation message in Laravel

0 likes
2 replies
Tray2's avatar

I recommend using http://regexr.com to test your regular expressions.

Something like

[a-z]{3}-[a-z]{3}-[a-z]{3}

should do the trick

1 like

Please or to participate in this conversation.