I am writing a regular expression which has multiple permutations and combinations. I did write the regex individually but how to combine them to make it a single regex. Please guide.
Allowed strings:
- combination of alphabets and numbers
- can have space in between
- can have special characters at start, end and in between also (cannot have # + \ ,)
- allowed examples for reference dfg, rt534, 34dfg, dfg(space)564(space)dfg545, !sdf7&*
Not allowed strings
- cannot have space at start and end
- cannot have # + \ , anywhere in the string
- cannot start with number but can be followed by an alphabet
- Ex: allowed - 445fsdf
- Ex: not allowed - 4
- not-allowed examples for reference 345, (space)sdfs, sdfsdf(space), #df8, sdfsdf(comma)4534
The individual regex I have are
^[A-Za-z0-9]*$
[^#+\\\,]
^[^\s]+(\s+[^\s]+)*$
Please guide me in combining the regular expressions.