I found this but i don't undertand it:
if [[ "${ARG//[IVXLCDM]/}" != "" ]]
then
echo "Wrong input"
fi
I found this but i don't undertand it:
if [[ "${ARG//[IVXLCDM]/}" != "" ]]
then
echo "Wrong input"
fi
This is a fairly crude test. It uses pattern expansion to assert whether a string is composed only of characters acceptable in Roman numerals w/o checking the semantics.
The // ... /
would replace any occurrence of any of the characters IVXLCDM
in the variable. Only if all of them are OK the result would be an empty string.
Why crude? Because it would happily accept MCCM
which is NOT a valid Roman numeral.
Edit:
As @LéaGris pointed out it will also accept an empty string as "Roman" and the test with inequality !=
is inefficient.