how can I test if a string matches a particular string matches regex with a basic (no bash or anything) posix shell script (in an if statement)?
You can use expr
command to evaluate regular expression in a POSIX shell:
s='Abc'
expr $s : '^[[:alpha:]]\+'
3
expr
returns # of matched characters which is 3 in this case.
Regular expression ^[[:alpha:]]\+
does the following:
^
: Match start positon
[[:alpha:]]\+
: Match 1 or more of any ASCII alphabets