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'...
-
I have discussed about conversion of DataTable to Generic List<t>. We can do it in various way. I want to share with you some of them....
-
Basically, a thin client is a web based application and most of the processing is done on the server side. A thick client is installed int...
-
Very recently I got a mail from a junior guy he faced a problem every time when he installed the SQL server database on his workstation. Bu...
No comments:
Post a Comment