Solved

Regular expression needed for a SharePoint column validation

Posted on 2013-06-16
11
823 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
  • 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
 
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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

The Scenario: Let’s say you have a quote worksheet in Excel that you use to work up sales figures and such for your clients. You utilize SharePoint to manage and keep track of these documents. You would like values from your worksheet to populate Sh…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now