![]() ![]() Let’s look at how to match an empty string with a positive lookahead: ^(?=\s*$) You can use them to create more complex regular expressions. ?= indicates a positive lookahead and ?! indicates a negative lookahead. There are both positive and negative lookaheads in RegEx. In RegEx, a lookahead is a zero-width assertion that allows you to match a string only if it is followed by another specific string without including that specific string in the match result. How to Match Empty String in RegEx with a Lookahead So, if you don’t put anything between both ^ and $, it matches an empty string: ^$ The caret ( ^) and dollar sign ( $) metacharacters match the start of a string and its end, respectively. How to Match Empty String in RegEx with the Caret and Dollar Sign Metacharacters How to Match Empty String in RegEx with a Negative Lookahead. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |