Esempio
Fare una ricerca globale per i caratteri che non sono spazi in una stringa:
var str = "Is this all there is?";
var patt1 = /\S/g;
Il testo contrassegnato qui sotto mostra dove l'espressione ottiene un match (matches everything except the whitespaces) :
Is this all there is?
Prova tu stesso " Definizione e l'utilizzo
Il metacarattere \ S viene utilizzato per trovare un carattere non-spazio bianco.
Un carattere di spazio bianco può essere:
- Un carattere di spazio
- Un carattere di tabulazione
- Un carattere restituito
- Una nuova linea carattere
- Un carattere di tabulazione verticale
- Un carattere di avanzamento
Supporto browser
Espressione | |||||
---|---|---|---|---|---|
\S | sì | sì | sì | sì | sì |
Sintassi
new RegExp("\\S")
or simply:
/\S/
Sintassi con modificatori
new RegExp("\\S","g")
or simply:
/\S/g
<JavaScript Object RegExp