I'm trying to figure out the correct way of using Regex to filter a String so that it's in this format exactly:
string1:string2
I've looked online through some documentation and I can't seem to get it working correctly. This is what I have so far and have tested:
^(\\w+)([:{0}])(\\w+)$^\\w[:]\\w$^\\w{1,}[:]{1}\\w{1,}$^[a-z]{1,}&&[:]&&{1}[a-z]{1,}$
I'm not sure why it does not work from what I read. However, I don't know much about Regex's and am probably making this more difficult than it is. Any help is appreciated, thank you.
EDIT: I have the String one working, however I now need to allow the String to have whitespace in it:
^[a-z]{1,}[:]{1}[a-z]{1,}$
e.g.string 1: string 1
EDIT 2: After realizing the user will probably have an unassertive amount of spaces, I have come to the conclusion that this works best:^.*[:].*$
Thanks.