正则表达式:在内容类型的http标头中匹配javascript mime类型

Looking for some way, I can verify the javascript content-type,
I have made

if(preg_match('/(text|application)\/javascript/i',$header){ #code ...

but this won't work all the cases because some servers reply with application/x-javascript
and my way verify application/javascript and text/javascript.

Your current answer is:

(text|application)\/(x-)?javascript

Will match x-javascript part too. Thats very small and basic change, I recommend you to study a bit more about regexp.
And you might find site regex101.com quite useful for your experiments.