Если вашей входной строкой является только URL (или N/A
), вы можете сделать это довольно легко с негативным прогнозом. Это не даст совпадения, если в любом месте в URL появится fbdcdn.net
.
(?!^.*?fbdcdn.net.*?$)^(?:http(?:s)?:\/\/(?:www\.)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:\/?#[\]@%!\$&'\(\)\*\+;=.]+$|(?:N\/A))$
По сути, это то же самое регулярное выражение, которое вы указали в вашем вопросе, с незначительными изменениями: (?!^.*?fbdcdn.net.*?$)^...$
(?! // Start negative lookahead (fail entire match if lookahead matches)
^ // Anchor to the start of the string
.*? // look for any characters (lazily)
fbdcdn.net // then match our forbidden string
.*? // then look for any more characters (lazily)
$) // before we find the end of our string, end lookahead
^ // anchor the pattern to the start of the string
... // your URL matching pattern
$ // anchor the pattern to the end of the string