2
17;#Nancy Williams;#894;#Brian Smith,;#895;#Kart Russell,

I tried ;# RegEx to split but the numbers and the comma after name are not needed.

Also, I have another scenario where the string looks like this

i:0#.w|domain\nWilliams;i:0#.w|domain\bSmith;i:0#.w|domain\kRussell;

Basically, I wanted the end result to look like domain\username; domain\username2... and so forth

and same for the first example.

torres
  • 1,283
  • 8
  • 21
  • 30
  • 1
    Why do you not want to parse the first case as an [`SPFieldLookupValueCollection`](http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldlookupvaluecollection.aspx)? – Rawling Nov 06 '12 at 13:49

1 Answers1

3

You can use

(;#)?[0-9]+;#

As your regular expression

lstern
  • 1,599
  • 14
  • 27
  • Okay, I finally have a situation where input variable looks like domain\username; domain\username2; domain\user3, etc. I am trying to regex ;# to split this into a collection variable. the regex puts the entire string (domain\user1....domain\userNth) into the collection variable. I think the regex ;# to split is not working. – torres Nov 06 '12 at 14:06
  • 1
    The string is exactly as you describe "domain\username; domain\username2; domain\user3 ..." if so, the ";#" isn't your separator anymore. Also, it's now a very simple separator and you don't even need a regexp, you can use .Split(';') – lstern Nov 06 '12 at 14:12
  • Actually, I didn't need the hash #. so all I needed is ; and that did that trick. Thank you Istern. – torres Nov 06 '12 at 15:06