Notice the two sets of non-capturing parentheses (?: around the annotation, but the use of regular capturing parentheses around the area code. Literal Parentheses are just that, literal text that you want to match. (True RegEx masters, please hold the, “But wait, there’s more!” for the conclusion). It’s the non-capturing parentheses that’ll throw most folks, along with the semantics around multiple and nested capturing parentheses. You’ll recognize literal parentheses too. You probably know about capturing parentheses. The 3 types of parentheses are Literal, Capturing, and Non-Capturing. Even so, I was still surprised when I learned that there are 3 different kinds of parentheses in regular expressions, not just 2.Īnd no, the 2 aren’t left and right, wise guy. If you’ve spent any time writing code you’ve no doubt abused regular expressions until they were an inscrutable character jumble that could give a real parser a run for its money.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |