Description
^(?!.*?[Pp]*(OST|ost)*\.*\s*[Mm][Aa][Nn]\s*(\d.)*)[a-z0-9A-Z-]*$

** To see the image better, simply right click the image and select view in new window
This regular expression will do the following:
- not allow your first expression to match anywhere in your string
- will then only allow
a-z
, A-Z
, 0-9
, and -
I would like to point out that if your string in only going to allow letters, numbers, and a hyphen then the test in your expression for a dot is not necessary. Also the multiple upper and lower case character sets can be removed by using the case insensitive flag.
Example
Live Demo
https://regex101.com/r/oY0hK2/1
Sample text
aWoeed1#fde39393aii
aWoeed1fde39393AII
aWoeed1fde39393AIIpostman 3a
Sample Matches
aWoeed1fde39393AII
Explanation
NODE EXPLANATION
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
(?! look ahead to see if there is not:
--------------------------------------------------------------------------------
.*? any character except \n (0 or more times
(matching the least amount possible))
--------------------------------------------------------------------------------
[Pp]* any character of: 'P', 'p' (0 or more
times (matching the most amount
possible))
--------------------------------------------------------------------------------
( group and capture to \1 (0 or more times
(matching the most amount possible)):
--------------------------------------------------------------------------------
OST 'OST'
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
ost 'ost'
--------------------------------------------------------------------------------
)* end of \1 (NOTE: because you are using a
quantifier on this capture, only the
LAST repetition of the captured pattern
will be stored in \1)
--------------------------------------------------------------------------------
\.* '.' (0 or more times (matching the most
amount possible))
--------------------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0
or more times (matching the most amount
possible))
--------------------------------------------------------------------------------
[Mm] any character of: 'M', 'm'
--------------------------------------------------------------------------------
[Aa] any character of: 'A', 'a'
--------------------------------------------------------------------------------
[Nn] any character of: 'N', 'n'
--------------------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0
or more times (matching the most amount
possible))
--------------------------------------------------------------------------------
( group and capture to \2 (0 or more times
(matching the most amount possible)):
--------------------------------------------------------------------------------
\d digits (0-9)
--------------------------------------------------------------------------------
. any character except \n
--------------------------------------------------------------------------------
)* end of \2 (NOTE: because you are using a
quantifier on this capture, only the
LAST repetition of the captured pattern
will be stored in \2)
--------------------------------------------------------------------------------
) end of look-ahead
--------------------------------------------------------------------------------
[a-z0-9A-Z-]* any character of: 'a' to 'z', '0' to '9',
'A' to 'Z', '-' (0 or more times (matching
the most amount possible))
--------------------------------------------------------------------------------
$ before an optional \n, and the end of the
string