verbalexpressions--Alternative Regular Expressions

Source: Internet
Author: User

Regular expressions are undoubtedly a very powerful tool for text processing. But writing and reading regular expressions is often not a very pleasant thing to do. This article introduces another kind of alternative regular expression--verbalexpressions, it uses the function chain to realize the expression of a turn colloquial, also can be very convenient similar to the regular expression string matching function.

1 [TestMethod]2          Public voidTestingifwehaveavalidurl ()3         {4             //Create An example by how to test for correctly formed URLs5             varVerbex =Newverbalexpressions ()6                         . StartOfLine ()7. Then ("http" )8. Maybe ("s" )9. Then ("://" )Ten. Maybe ("www." ) One. Anythingbut (" " ) A                         . EndOfLine (); -  -             //Create An example URL the             varTestme ="https://www.google.com"; -  -Assert.istrue (Verbex.test (Testme),"The URL is incorrect"); -  +Console.WriteLine ("We have a correct URL"); -}

It is also available in a variety of other languages and can be viewed on its homepage.

As can be seen from the above example, it is very easy to read and the learning threshold is relatively low. Of course, its use of the scope and function should be less than the regular expression so powerful. While I think regular expressions are a must-have for programmers, at some point these easy-to-read expressions are a good choice.

verbalexpressions--Alternative Regular Expressions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.