I have a problem about the pronunciation of "st". I read that it is pronounced "sht" when it appears in the first syllable but I saw some words when it is pronounced "sht" in the middle. for example: Verstehen, Einstein. I want to ask if those words are just exceptions ?
Basically, the rule you read was incomplete. It's pronounced as sht (from now on /ʃt/) if the cluster is at the start of a syllable. Some examples:
Just like any other rule in the German language, there are exceptions. I picked
still previously on purpose to show that orthography is not always to be trusted. Mostly because of foreign words. Something that comes immediately to mind is the word
As you can hear from the recording, the first sound wasn't /ʃt/, but a simple /st/.
If separating words into syllables isn't exactly intuitive, and you're dealing with a compound word, try separating the root words.
Haltestelle - halte/stelle
If you're dealing with prefixes eliminate them.
bestrafen - be/strafen
Lastly, if you have the chance, check websites like forvo.
No, these words are not exceptions. The phenomenon you are observing is quite common. The rule that you are quoting holds also when words are composed or used with a prefix: ver-stehen (prefix "ver", base word "stehen"), Ein-stein (it's a name anyway, but same principle), aus-steigen, Fahr-stuhl (composition of "fahren" and "Stuhl") and so on.
At first: there are some German dialects (in the hanseatic region), where st and sp is not pronounced sht and shp respectively but at face value. I agree with clinch, that in most cases and most regions, it is pronounced sht and shp. Unfortunately there are exceptions, especially at the end of a word (Last, Lust, Mast, fast, List), if the s is doubled to shorten the preceeding vowel (frisst) and of course, where a composite word was formed and the word border runs between s and t like Mus-topf (literally a jar holding purée, used in negative context like in the phrase "aus dem Mustopf kommen" meaning "being narrow-minded, limited").