Anyone know the error checking for special characters
2 次查看(过去 30 天)
显示 更早的评论
Hello there, I've been at this for a while now but i just can't seem to to find the error check for special characters like, * @!. Please help
回答(1 个)
Udit Gupta
2015-4-27
You can use regular expressions. The code will go something like this -
if any(regexp(str,'[^_a-zA-Z0-9]+'))
<error condition>
end
You will need to use a more sophisticated regEx format if you need more robust checking. Like:
if any(regexp(str,'^[a-zA-Z_][a-zA-Z0-9_]*$'))
<valid>
else
<invalid>
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!