முக்கிய உள்ளடக்கத்திற்குச் செல்லவும்
eLearner.app
தொகுதி 5 · பாடம் 3 இன் 4பாடத்திட்டத்தில் 19/32~8 min
தொகுதி பாடங்கள் (3/4)

மறுப்பு: `[^...]`

Placing a caret ^ as the first character inside brackets inverts the class: it matches any character except those listed.

Code
Pattern: [^aeiou]
Sample:  ciao mondo
          ^   ^^  ^

[^aeiou] matches consonants, spaces, punctuation, digits\u2026 everything that is not a vowel.

Typical examples

  • [^\s] -- any "non-space" character (equivalent to \S).
  • [^0-9] -- anything that is not a digit (equivalent to \D).
  • [^"]+ -- "a sequence of characters that are not double quotes" (useful to extract content between quotes).
Code
Pattern: "([^"]+)"
Sample:  Il libro "Il nome della rosa" e' famoso.

The group ([^"]+) captures everything between quotes stopping before the next ": it is a classic trick to avoid the greedy-vs-lazy problem.

Negation and alternative wildcards

The negated class [^...] consumes exactly one character that is NOT part of the listed set. It is a powerful tool to prevent the engine from running past critical delimiters, avoiding ReDoS caused by infinite backtracking loops.

Try it

உடற்பயிற்சி#regex.m5.l3.e1
முயற்சிகள்: 0ஏற்றுகிறது…

Extract the content of every string between double quotes, without capturing the quotes themselves.

எடிட்டரை ஏற்றுகிறது…
குறிப்பைக் காட்டு

Replace .+ with [^"]+: this way the match stops at the next quote.

3 முயற்சிகளுக்குப் பிறகு தீர்வு கிடைக்கும்

Review exercise

உடற்பயிற்சி#regex.m5.l3.e2
முயற்சிகள்: 0ஏற்றுகிறது…

Find every word made up ONLY of consonants (no vowels, no digits, no symbols).

எடிட்டரை ஏற்றுகிறது…
குறிப்பைக் காட்டு

Inside the brackets you can combine vowel negation with \\W (non-word) and \\d (digits).

3 முயற்சிகளுக்குப் பிறகு தீர்வு கிடைக்கும்

Additional challenge

உடற்பயிற்சி#regex.m5.l3.e3
முயற்சிகள்: 0ஏற்றுகிறது…

Match sequences of one or more characters, explicitly excluding whitespace and commas.

எடிட்டரை ஏற்றுகிறது…
குறிப்பைக் காட்டு

Use [^\s,] with the + quantifier.

3 முயற்சிகளுக்குப் பிறகு தீர்வு கிடைக்கும்