Consider the following rules:
register *
delete *
suppose now if I send a message to the application (via mobile using SMS) that will match the rules
- register Leon Eric
now we have two parameter Leon and Eric and the application will assign %P1% for Leon and %P2% for Eric , for further use.
it can be more parameters every parameters have its variable %P1% %P2% %P3% .... %Pn%
the application will reply a custom message that can be changed by the user :
Thank you %P1% %P2% for your register.
since %P1% is Leon and %P2% is Eric
the message will be "Thank you Leon Eric for your register."
my questions :
What is the best technique I should use with this situation is it regular expression?
I tried to use the regular expression to extract the parameters but how to group every parameter with name %P1% %P2% ….%Pn% for furt开发者_如何学JAVAher use.
register.? (.+).?
What is the best technique I should use to replace the message that have an argument with
the parameter that the regular expression assign ?
For example:
Thank you %P1% %P2% for your register.
"Thank you Leon Eric for your register."
thank you very much
You don't need any regex here, just use %*
to list all parameters:
Thank you %*% for your register.
精彩评论