Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Regular Expression for last six characters

Author  Topic 

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2006-08-14 : 10:09:31
Hello!

I'm pretty new to expression, and I'm using an autocomplete text box for a user to enter a value.

What I need to do is check for a space, then the pipecleaner, then a space, then a value that's b/n 000000 and 999999 on the end of my string. So, it's really 9 characters from the right.

So far I've got this, but it doesn't check for the pipecleaner. It only checks for the last six characters, and makes sure they're numbers:

\d{6}$


Thanks!

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2006-08-14 : 13:42:01
I'm trying the following in a code behind subroutine, and it's not working. If the value they select is CORRECT, the exeption is still thrown.

txtWPMgr.Text should get built from a SQL string the does a select colName+' | '+colNumber

It's the colNumber value I want to compare in this expression.

Dim regEx As New Regex("^\s\w\s\d{6}$")
'last six characters are digits

If Len(Trim(txtWPMgr.Text)) > 0 Then
'Means there are characters for the name
If InStr(txtWPMgr.Text, " | ") = 0
Or Not regEx.IsMatch(Trim(txtWPMgr.Text)) Then
intDisable = 1 'Mark integer flag
lblStatus.Text = "Bad Format!"
End If
Go to Top of Page

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2006-08-14 : 15:50:03
I got it with:
'Start Expression Code
Dim regEx As New Regex("\s\|\s\d{6}$") 'last six characters are digits for number
If Len(Trim(strNewPerson)) > 0 Then 'Means there are characters for the name
If InStr(strNewPerson, " | ") = 0 Or Not regEx.IsMatch(Trim(strNewPerson)) Then
lblStatus.Text = "* Name value must be from dropdown list built when typing name(last name first)!"
Exit Sub
Else
lblStatus.Text = String.Empty
End If
End If
'End Expression code

Thanks!
Go to Top of Page
   

- Advertisement -