Anyone know the error checking for special characters
Show older comments
Answers (1)
Udit Gupta
on 27 Apr 2015
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
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!