Skip to main content

String Utilities

A collection of commonly used string utilities

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace SecretOrange
{
    public class StringUtils
    {
        public static IList<string> SplitOnNewLines(string source)
        {
            return Regex.Split(source, @"\r?\n").Where(d => !String.IsNullOrWhiteSpace(d)).ToList();
        }

        public static string ReplaceNewlinesWithBr(string source)
        {
            var lines = SplitOnNewLines(source);
            return String.Join("<br/>", lines);
        }
    }
}

Hello, my name's Lee and I work as a full-stack web developer specialising in Microsoft ASP.NET technologies. I love using Umbraco and also MANAGED, my own interal CMS.

Contact me at lee.gunn@secretorange.co.uk

All skills

Contact

Get in touch to talk about your project or just ask me a question.

lee.gunn@secretorange.co.uk

Skype: lee_gunn