• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

Reg Exp how to search for only numbers, letters, and spaces

I'm trying to allow only letters, numbers and spaces when checking a value.

The code below only allows letters and numbers, but not spaces.

How do I change the .Pattern to allow spaces too.

'Use regexp to make sure that password has only chars a-z and 0-9
Set RegularExpressionObject3 = New RegExp
With RegularExpressionObject3
    .Pattern = "\W+"
    .IgnoreCase = True
    .Global = True
End With
expressionmatch3 = RegularExpressionObject3.Test(TempVal)
     If expressionmatch3 = true Then ErrorCode = 3
Set RegularExpressionObject3 = Nothing


Thanks!
0
zippyuk
Asked:
zippyuk
1 Solution
 
lavinderCommented:
try to use
 .pattern="\W+\s+"
0
 
gladxmlCommented:
zippyuk,

try to use this

.pattern="\w+\s+"

this will search for alaphanumeric numeric

HTH...

HAppy programming...
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now