Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby * match in string

Tags:

regex

ruby

match

I need to detect * in string

I try x =~ /*/ and x =~ "/*/"

Both variants are incorrect

Please give me advice

like image 980
Vyacheslav Loginov Avatar asked Dec 10 '25 09:12

Vyacheslav Loginov


1 Answers

* is a quantifier in regular expressions. You need to escape it.

s =~ /\*/
like image 185
Sergio Tulentsev Avatar answered Dec 12 '25 22:12

Sergio Tulentsev