Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
<table>
<tr>
<td><strong>pint</strong></td>
<td>/[\d]/</td>
</tr>
<tr>
<td><strong>int</strong></td>
<td>/[\d\-]/</td>
</tr>
<tr>
<td><strong>pnum</strong></td>
<td>/[\d\.]/</td>
</tr>
<tr>
<td><strong>money</strong></td>
<td>/[\d\.\s,]</td>
</tr>
<tr>
<td><strong>num</strong></td>
<td>/[\d\-\.]/</td>
</tr>
<tr>
<td><strong>hex</strong></td>
<td>/[0-9a-f]/i</td>
</tr>
<tr>
<td><strong>email</strong></td>
<td>/[a-z0-9_\.\-@]/i</td>
</tr>
<tr>
<td><strong>alpha</strong></td>
<td>/[a-z_]/i</td>
</tr>
<tr>
<td><strong>alphanum</strong></td>
<td>/[a-z0-9_]/i</td>
</tr>
</table>
<br />
<br />
<h:form>
<h:panelGrid columns="2">
<h:outputText value="KeyFilter with regEx on a p:inputText" />
<p:inputText id="text1">
<p:keyFilter regEx="/[ABC]/i"/>
</p:inputText>
If you need to avoid characters in the view (input text) you can user p:keyFilter
tag as below
<p:inputText id="apePat"
placeholder="Apellido Paterno"
value="#{actualizaDatos.user.apePat}"
autocomplete="off"
label="Apellido Paterno"
validatorMessage="El campo apellido paterno es requerido">
<f:validateRequired/>
</p:inputText>
-------------------------------
How do I write a regular expression that includes all keyboard characters except
'~' and ','?
Have you tried this?
[^~,]
Now to exclude characters not in keyboard, I believe you have to include them all.
[a-zA-Z0-9\t\n ./<>?;:"'`!@#$%^&*()\[\]{}_+=|\\-]
Which pretty much covers it (even though it looks like a crazy way to get things
done). Maybe the problem definition can help you add more stuffs to exclude in the
first list [^~,] than try to create a huge list of all keyboard chars
You didn't say what language/tool you're using, but in Java I would go with this
regex:
"[\\p{Print}&&[^~,]]"
That's the intersection of two sets: all printing ASCII characters, and all
characters that aren't a tilde or a comma.
This worked for me:
[A-Za-z0-9-]+[ 0-9A-Za-z#$%=@!{},`~&*()'<>?.:;_|^/+\t\r\n\[\]"-]*
A related one.
// example tests
var nonShiftChars = "`1234567890-= qwertyuiop[]\asdfghjkl;'zxcvbnm,./ "
var shiftChars = "~!@#$%^&*()_+{}|:\"<>? ";
var someAlphaNumeric = "aAbB12 89yYzZ";
/^[a-zA-Z0-9.!@?#"$%&:';()*\+,\/;\-=[\\\]\^_{|}<>~` ]+$/