Solved

Regular expression needed for a SharePoint column validation

Posted on 2013-06-16
11
1,082 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
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…

627 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