Du vill att någon av ?*:\"><|/ inte skall matchas?
Det känns att mönstret inte riktigt stämmer när jag kollar på den.
Är det ett filnamn den ska kolla upp(samma mönster som windows maskiner har?)
Är det endast vad filen slutar på du skall kontrollera?
Jag bifogar vad RegExp buddy skickar till mig som beskriver ditt uttryck:
"^" + // Assert position at the beginning of a line (at beginning of the string or after a line break character)
"(?!" + // Assert that it is impossible to match the regex below starting at this position (negative lookahead)
"^" + // Assert position at the beginning of a line (at beginning of the string or after a line break character)
"(" + // Match the regular expression below and capture its match into backreference number 1
// Match either the regular expression below (attempting the next alternative only if this one fails)
"PRN" + // Match the characters “PRN” literally
"|" + // Or match regular expression number 2 below (attempting the next alternative only if this one fails)
"AUX" + // Match the characters “AUX” literally
"|" + // Or match regular expression number 3 below (attempting the next alternative only if this one fails)
"CLOCK" + // Match the characters “CLOCK” literally
"\\$" + // Match the character “$” literally
"|" + // Or match regular expression number 4 below (attempting the next alternative only if this one fails)
"NUL" + // Match the characters “NUL” literally
"|" + // Or match regular expression number 5 below (attempting the next alternative only if this one fails)
"CON" + // Match the characters “CON” literally
"|" + // Or match regular expression number 6 below (attempting the next alternative only if this one fails)
"COM" + // Match the characters “COM” literally
"\\d" + // Match a single digit 0..9
"|" + // Or match regular expression number 7 below (attempting the next alternative only if this one fails)
"LPT" + // Match the characters “LPT” literally
"\\d" + // Match a single digit 0..9
"|" + // Or match regular expression number 8 below (the entire group fails if this one fails to match)
"\\." + // Match the character “.” literally
"." + // Match any single character that is not a line break character
"*" + // Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
")" +
"(" + // Match the regular expression below and capture its match into backreference number 2
"\\." + // Match the character “.” literally
"." + // Match any single character that is not a line break character
"+" + // Between one and unlimited times, as many times as possible, giving back as needed (greedy)
")?" + // Between zero and one times, as many times as possible, giving back as needed (greedy)
"$" + // Assert position at the end of a line (at the end of the string or before a line break character)
")" +
"(?!" + // Assert that it is impossible to match the regex below starting at this position (negative lookahead)
"." + // Match any single character that is not a line break character
" " + // Match the character “ ” literally
"*" + // Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
"\\s" + // Match a single character that is a “whitespace character” (spaces, tabs, line breaks, etc.)
"\\s" + // Match a single character that is a “whitespace character” (spaces, tabs, line breaks, etc.)
")" +
"[^\\x00-\\x1f\\\\?*:\\\"\"><|/]" + // Match a single character NOT present in the list below
// A character in the range between ASCII character 0x00 (0 decimal) and ASCII character 0x1f (31 decimal)
// A \ character
// One of the characters “?*:”
// A " character
// One of the characters “"><|/”
"+" + // Between one and unlimited times, as many times as possible, giving back as needed (greedy)
"$" // Assert position at the end of a line (at the end of the string or before a line break character)
Stämmer detta?
