Regular expression to match a line that doesn’t contain a word

The notion that regex doesn’t support inverse matching is not entirely true. You can mimic this behavior by using negative look-arounds: ^((?!hede).)*$ Non-capturing variant: ^(?:(?!:hede).)*$ The regex above will match any string, or line without a line break, not containing the (sub)string ‘hede’. As mentioned, this is not something regex is “good” at (or should … Read more

Learning Regular Expressions [closed]

The most important part is the concepts. Once you understand how the building blocks work, differences in syntax amount to little more than mild dialects. A layer on top of your regular expression engine’s syntax is the syntax of the programming language you’re using. Languages such as Perl remove most of this complication, but you’ll … Read more

How can I validate an email address using a regular expression?

The fully RFC 822 compliant regex is inefficient and obscure because of its length. Fortunately, RFC 822 was superseded twice and the current specification for email addresses is RFC 5322. RFC 5322 leads to a regex that can be understood if studied for a few minutes and is efficient enough for actual use. One RFC … Read more

Reference – What does this regex mean?

The Stack Overflow Regular Expressions FAQ See also a lot of general hints and useful links at the regex tag details page. Online tutorials RegexOne ↪ Regular Expressions Info ↪ Quantifiers Zero-or-more: *:greedy, *?:reluctant, *+:possessive One-or-more: +:greedy, +?:reluctant, ++:possessive ?:optional (zero-or-one) Min/max ranges (all inclusive): {n,m}:between n & m, {n,}:n-or-more, {n}:exactly n Differences between greedy, … Read more