Regular Expression for Multiple options.
-
I have requiremen like below
I need to write a regular expression for below match
String should start with some charachters and end with digits
something like
ayush1 or gupta1I was trying like this
^\ayush|gupta[0-9]$
But id did not helped.
Basically my requirement to write a regular expression with multiple string options to be matched followed by some sequence of charachters.
So in above case ayush1 should be matched and gupta1 should be matched. and we can give as many string like ayush , gupta for matching with OR option and it should followed by some sequence of charachters only which we will provide in regex.
-
Hi
You can use
https://regexr.com/
to practice.
makes it easier to get it right. -
I tried but not reaching to my requirements :(
-
Hi,
One good site to test regular expression is regex101.com
Based on your explanation it seems that
^\w+\d+?$
is what you are looking for.Note that Qt provides the QRegularExpression tool example that allows to test your regular expressions as well as get the string equivalent you need ot use in your code.
For example, my suggestion becomes
^\\w+\\d+?$
-
@vronin Great Thanks