Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Parse String

  Asked By: Ralph    Date: Oct 28    Category: Sharepoint    Views: 1624

Have column called Document ID which stored this: listItem["Document ID"] =
properties.ListItem.ParentList.ParentWeb.Title.ToString() + "-" +
properties.ListTitle.ToString() + "-" + properties.ListItem.UniqueId.ToString();

This code will give me something like this: Line 4
Project-Administration-aa8bf828-27c2-486f-acc8-25kk5bkak

How do I parse the string so that Line 4
Project-Administration-aa8bf828-27c2-486f-acc8-25kk5bkak would look like this
L4P-Adm-aa8bf828

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Arti Patel     Answered On: Oct 28

Assuming the Document ID column  is a single line  of text column, and that you
know the string  you want to replace with a substring you can use the
String.Replace method. The code  you want would be something like this.

string tempString = properties.ListItem.ParentList.ParentWeb.Title.ToString() +
"-" + properties.ListTitle.ToString() + "-" +
properties.ListItem.UniqueId.ToString();
tempString.Replace("Line 4 Project-Administration", "L4P-Adm");
listItem["Document ID"] = tempString;

If you are looking for a way to build the replace string programmatically, I
suspect that there are too many possibilities to automate it and you would need
some kind of workflow to ask a human to abbreviate the string. Then use the
abbreviation in the code above.

 
Didn't find what you were looking for? Find more on Parse String Or get search suggestion and latest updates.




Tagged: