As per the requirement I need to generate a regex to match a String that doesn't start or end with space. Apart from that the string should not end with a special character dot(.). As per my understanding I've generated a regex "\\S(.*\\S)?$"
which restrict the string that has a space at the beginning and at the end of the string. With this expression I need to validate the regex for string that ends with dot. Any sort of help would be appreciated.
Use following regex
^\S.*[^.\s]$
Regex explanation here
If you want to match single character then you can use look-ahead and look behind-assertion.
^(?=\S).+(?<=[^.\s])$
Regex explanation here
If look-behind not supports then use
^(?=\S).*[^.\s]$
Regex explanation here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With