Solved

Regular expression needed for a SharePoint column validation

Posted on 2013-06-16
11
1,009 Views
Last Modified: 2013-06-17
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).
0
Comment
Question by:MisUszatek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 35

Assisted Solution

by:Terry Woods
Terry Woods earned 100 total points
ID: 39252195
Perhaps try this?

AB[0-9]{7}

Open in new window

0
 
LVL 23

Expert Comment

by:nemws1
ID: 39253355
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
 

Author Comment

by:MisUszatek
ID: 39253482
@TerryAtOpus
I get the following error message when using this formula: The formula contains a syntax error or is not supported.
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 23

Expert Comment

by:nemws1
ID: 39253564
Terry's RegEx looks just fine to me (it should work).  Maybe try this:
AB\d{7}

Open in new window

0
 
LVL 23

Expert Comment

by:nemws1
ID: 39253565
BTW - those are curly braces, not parenthesis.
0
 

Author Comment

by:MisUszatek
ID: 39253617
It still gives me an error. Maybe SharePoint needs specific syntax for this to work?
0
 

Author Comment

by:MisUszatek
ID: 39253625
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
 
LVL 23

Accepted Solution

by:
nemws1 earned 200 total points
ID: 39253638
Okay... that looks much more like Excel syntax rather than a RegEx (which I thought Sharepoint *did* support)
0
 
LVL 23

Expert Comment

by:nemws1
ID: 39253683
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
 

Author Comment

by:MisUszatek
ID: 39253695
I am good for now - thank you all for help.
0
 

Author Comment

by:MisUszatek
ID: 39253708
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

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question