jeudi 21 décembre 2017

Regex Detect Double Space

I am trying to get a regex that will detect if there is a double space in a string. But if it does detect a double space it will return as false. So essentially anything else in the string is valid except for two spaces side by side. In the examples below the underscores (_) are spaces.

'Hello_World' ==> Valid

'Hello__World' ==> Invalid

'Hello___World' ==> Invalid

'1_2_3_4_5' ===> Valid

'1_2_3__4_5' ==> Invalid

This is my current regex

/^([^/s/s]*)$/

Aucun commentaire:

Enregistrer un commentaire