0

i have a template for sending messages, in those some {words} are variable.how can i compare these template against sentences and check whether it is success or failed (if possible with percentage of changes)

Template sample :

Hi {var}, Your last call was from {var} at {var} {var} was {var}.
Thank you for using Cloud PBX Services.

Success Message :

Hi Alex, Your last call was from 1234567890 at 10:30 AM was ANSWERED
Thank you for using Cloud PBX Services.

Success Message :

Hi Mary, Your last call was from 6789012345 at 11:30 PM was BUSY
Thank you for using Cloud PBX Services. 

Failed Message :

Hi Joe, Your bank account is credited with 1000Rs at 11:30 PM  
Thank you for using Cloud PBX Services.

predefined compare function using kannel library

regex_t *gw_regex_comp_real(const Octstr *pattern, int cflags, const char *file,
                            long line, const char *func)
{
    int rc;
    regex_t *preg;

    preg = gw_malloc(sizeof(regex_t));

    if ((rc = regcomp(preg, pattern ? octstr_get_cstr(pattern) : NULL, cflags)) != 0) {
        char buffer[512];
        regerror(rc, preg, buffer, sizeof(buffer));
        error(0, "%s:%ld: %s: regex compilation `%s' failed: %s (Called from %s:%ld:%s.)",
              __FILE__, (long) __LINE__, __func__, octstr_get_cstr(pattern), buffer,
              (file), (long) (line), (func));
        gw_free(preg);
        return NULL;
    }

    return preg;
}
Vinayak
  • 305
  • 2
  • 11
  • Does the C language have `regex_t`? The C++ language has regex support. – Thomas Matthews Nov 18 '22 at 02:05
  • i think its C++ – Vinayak Nov 18 '22 at 02:06
  • You could improve your question by telling us what the formats of each "variable" part is. Yes, we could infer, but we might infer wrong. I might actually suggest you try to pose a more [minimal/generalized version of your question](https://stackoverflow.com/help/minimal-reproducible-example). If you do that, your question(s) will be more likely to be able to help others. In the process of minimizing/generalizing your question, you might even ask some smaller questions and find that answers already exist for them. – starball Nov 18 '22 at 02:07
  • its alphanumeric character, and it varies in each sms – Vinayak Nov 18 '22 at 02:10
  • I think you are asking few different small questions that already have been answered in many places. [C++ regex docs](https://en.cppreference.com/w/cpp/regex); [regex for name](https://stackoverflow.com/questions/2721768/regular-expression-to-match-a-name); [regex for time](https://stackoverflow.com/questions/7536755/regular-expression-for-matching-hhmm-time-format); etc ... – pptaszni Nov 18 '22 at 13:09

0 Answers0