I have a string of the format: string:num where num is any number but string is a known string that I need to match on. I’d like to have this in an if statement as:
if( it matches 'string:' followed by a number) {
//do something
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You want …
This includes:
^beginning of the stringstring:the literal “string:” you mentioned(.....)This subexpression, which you can refer to later if you need to know which number is in the string (though in this particular case, you could also just replace'string:'with'')[0-9]a character between0and9(i.e., a digit)+Must have at least one “of those” (i.e., digits mentioned above), but can have any number$end of the string