Hello i tried below code using regex
$str = preg_replace("/[^a-z0-9_]/i", '', 'New_text % *');
//output => New_text
( _ is except char )
all work perfect but when my input string something like in other language(ex Hindi), char in Hindi Lang will also delete.
same as above example
$str = preg_replace("/[^a-z0-9_]/i", '', 'कपिल शर्मा % * _');
//output => _
how to get: कपिल शर्मा _
is there any mistake in regex or any other way in PHP we can do?
\Winstead of the full character range. Also add theumodifier.a-zdoes not cover Hindi letters should be obvious … those are Latin letters.a-z0-9is simple and specific. "And also Hindi" is very wide, vague and unspecific. What about Arabic, Japanese and other languages?