Anyone know the error checking for special characters
조회 수: 1 (최근 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!