Regular expression needed for a SharePoint column validation

I need a column validation (SharePoint 2010) to check if the value is in a proper format. The format is: AB1234567 (capital A, capital B and then 7 digits).
MisUszatekAsked:
Who is Participating?
 
nemws1Connect With a Mentor Database AdministratorCommented:
Okay... that looks much more like Excel syntax rather than a RegEx (which I thought Sharepoint *did* support)
0
 
Terry WoodsConnect With a Mentor IT GuruCommented:
Perhaps try this?

AB[0-9]{7}

Open in new window

0
 
nemws1Database AdministratorCommented:
Speaking of, can anyone verify *which* of Microsoft's multiple RegEx implentations Sharepoint uses?  Is it the same one as C#?

http://msdn.microsoft.com/en-us/library/az24scfc.aspx
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
MisUszatekAuthor Commented:
@TerryAtOpus
I get the following error message when using this formula: The formula contains a syntax error or is not supported.
0
 
nemws1Database AdministratorCommented:
Terry's RegEx looks just fine to me (it should work).  Maybe try this:
AB\d{7}

Open in new window

0
 
nemws1Database AdministratorCommented:
BTW - those are curly braces, not parenthesis.
0
 
MisUszatekAuthor Commented:
It still gives me an error. Maybe SharePoint needs specific syntax for this to work?
0
 
MisUszatekAuthor Commented:
Using instructions from the internet i was able to create this formula that works:

=(LEN([Case #])=9)
+(MID([Case #],1,1)="A")
+(MID([Case #],2,1)="B")
+(CODE(MID([Case #],3,1))>47)
+(CODE(MID([Case #],3,1))<58) 
+(CODE(MID([Case #],4,1))>47)
+(CODE(MID([Case #],4,1))<58) 
+(CODE(MID([Case #],5,1))>47)
+(CODE(MID([Case #],5,1))<58) 
+(CODE(MID([Case #],6,1))>47)
+(CODE(MID([Case #],6,1))<58) 
+(CODE(MID([Case #],7,1))>47)
+(CODE(MID([Case #],7,1))<58) 
+(CODE(MID([Case #],8,1))>47)
+(CODE(MID([Case #],8,1))<58) 
+(CODE(MID([Case #],9,1))>47)
+(CODE(MID([Case #],9,1))<58) 
=17

Open in new window


I am still wondering if there is an easier way to do it...
0
 
nemws1Database AdministratorCommented:
According to this, you *can* use a RegEx, but you would need to use a custom field and write some C# code in order to call RegEx().  Probably too much of a headache.

http://msdn.microsoft.com/en-us/library/ms434697.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
0
 
MisUszatekAuthor Commented:
I am good for now - thank you all for help.
0
 
MisUszatekAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for MisUszatek's comment #a39253625
Assisted answer: 100 points for TerryAtOpus's comment #a39252195
Assisted answer: 200 points for nemws1's comment #a39253683

for the following reason:

Own solution.
0
All Courses

From novice to tech pro — start learning today.