Zero-width assertions

Publié le: 01 janvier 2022
sur la chaîne: Regex Quickies with Wiktor Stribiżew
419
19

Zero-width assertions are common regex constructs that allow matching patterns in specific contexts: at the start or end of a string or a word, after a certain word or before a specific character. You must have heard and used anchors, word boundaries, lookaheads and lookbehinds in your patterns, and these are all examples of zero-width assertions.

REGEX FIDDLE: https://regex101.com/r/JlOmlT/1

FURTHER LINKS
https://rexegg.com/regex-boundaries.html - Word boundaries
https://rexegg.com/regex-anchors.html - Anchors
https://www.regular-expressions.info/... - Lookahead and Lookbehind Zero-Length Assertions
https://rexegg.com/regex-lookarounds.... - Mastering Lookahead and Lookbehind
https://stackoverflow.com/a/43232659/... - match anywhere but at the string start
https://stackoverflow.com/a/35271748/... - match a line feed char if not preceded with semi-colon
https://stackoverflow.com/a/40942385/... - match until first instance of certain character
https://stackoverflow.com/a/32477224/... - ensure the whole string has a specific length (`\A(?=.{1,15}\Z)`)
https://stackoverflow.com/a/51134786/... - match up to a char or end of string (`(?=&|$)` = `(?![^&])`)


Sur cette page du site, vous pouvez voir la vidéo en ligne Zero-width assertions durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Regex Quickies with Wiktor Stribiżew 01 janvier 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 419 fois et il a aimé 19 téléspectateurs. Bon visionnage!