Regular Expression Matching

Source: Internet
Author: User



There are two points to note:

The Meaning of "*" represents 0 or more repetitions of the characters preceding it. If "A *" stands for ' a ' followed by 0 or more characters ' a ';

Second, the use of C + + implementation of the following function is a string type, here by character processing when there are many inconvenience, can be converted to char * for processing.

Class Solution {public:    bool Ismatchchar (const char *s, const char *p) {if (*p = = ') ' return *s = = ' + '; if (* (p + 1)! = ' * ') {if (*s! = ' && (*p = = *s | | *p = = '. ')) {return Ismatchchar (S + 1, p + 1);} Else{return false;}} Else{while (*s! = "&&" (*s = = *p | | *p = = '. ')) {if (Ismatchchar (s, p + 2)) return true;s++;} Return Ismatchchar (S, p + 2);}} BOOL IsMatch (string s, String p) {    int lens = S.length ();    int LENP = P.length () char* Schar = new Char[lens + 1];char* Pchar = new CHAR[LENP + 1];strcpy (Schar, S.c_str ()); strcpy (PC Har, P.c_str ()); Schar[lens] = ';p char[lenp] = ' Schar ', return Ismatchchar




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Regular Expression Matching

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.