Last day I have faced a problem for a long string like(adfdsfsdfdsfdsfsdafdsfsdfsdfsdfsdfsdfsdfsdfsdffdsfsdfsdfsdafsdfsdfsdfsdfsdfsdafsdf) which make my application's UI design break. So to fixed this issue I have used regular expression which insert a space after n characters.
To insert a space after every n characters:
var newString = Regex.Replace(oldString, new string('.', n), m => m.Value + " ");
Sample solution:
string longWord = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaassssssssssssssssssssssssdddddddddddddddddddddddddddddaaaaaaaaaafffffffffffffffffffffffffadfdsfsdfdsfdsfsdafdsfsdfsdfsdfsdfsdfsdfsdfsdffdsfsdfsdfsdafsdfsdfsdfsdfsdfsdafsdffdsfdsfdsfsdf";
Regex.Replace(longWord, new string('.', 16), m => m.Value + " ");
In above image it shows that regex place a space after every 16 character for that long string.
Sharing real-world experiences about C#, Dynamics CRM, Dynamics 365, Dynamics NAV/Business Central, SharePoint,PowerBI,ASP.net and more...
Subscribe to:
Post Comments (Atom)
Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'
Exception: Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'...
-
How to get the MAC address of system using Asp.net/C# Now I want to share with you some simple but important for our rapid development. ...
-
Last night I have got this mail from Microsoft MVP award program manager. “Dear Ahsan Murshed, Congratulations! We are pleased to presen...
-
I have little bit confusion about HTTP Handler and HTTP Module. Then I move to community and get a huge response. After studying for a while...
No comments:
Post a Comment