I need to create regular expression for the word not starting with dot and it may contains any alphabet,space and dot.
Ex: sample,sample.test,sample test
regular expression should not allow .sample,sample.,sample .test
how to generate regular expression for this?
This regex:
^[^.][\p{L} .]+$should match what you are after.The
^is an anchor which will instruct the regex engine to start matching from the very beginning of the string.[^.]will match any 1 character which is not a period (.).[\p{L} .]+will match one ore more characters which is either a letter (in any language as shown here), a white space or a period. Finally, the$will instruct the regex to terminate matching at the end of the string.EDIT: As per your comment question, something like so should be testable:
^[^.][a-zA-Z .]+$.