regex for expression with one separator hyphen

I’m going to use regex for matching expressions, which:

  1. Separated by one (and only one) hyphen
  2. Each of the two parts do not contain any spaces

So, it matches:

ss-ss
12-s2
11-11
%@2s-#1

And does not match:

s s-ss
ss-s s
s s-s s
1 s-1s
1s-1 s
1 s-1 s
ss-ss-ss
s1-s2-s3

Is there any way to create with regex?

I tries something like:

^.[^ ]-[^ ]*

But it matches only expressions with any number of hyphens, and whatever space occurrence, for example

 ss-ss-ss
 1 s-1 s

Read more here: Source link