Wednesday, July 31, 2019

c# Modern Human Readable Timespan fast using Stringbuilder and variable length formatting


Here's a great modern way to format C# timespan to be human readable number. It uses StringBuilder (for speed) and Action delegate for variable length formatting. Actually, you could simply add custom string formatting to each time unit.




This implementation will leave out zero units parts.  Say that minutes is 0, it will not print 0 mins place to save space of output string.




 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System; using System.Collections.Generic; using System.Text; 
using System.Diagnostics; 
     
public static class Program
{
 /// <summary>
 ///  Human readable TimeStamp using modern Action delegate, leaving out zero parts and variable length formating 
 /// </summary>
 /// <param name="milliseconds">a long type</param>
 /// <returns>Human readable timespan string</returns>
 public static string HumanReadableTimeSpan(this long milliseconds)
 {
  if (milliseconds == 0) return "0 ms"; 

  StringBuilder sb = new StringBuilder(); 
  
  Action<int, StringBuilder, int> addActionToSB =  //or pass an entire new format!
  (val, displayunit, zeroplaces) => 
  {if (val > 0) 
   sb.AppendFormat(
     " {0:DZ}X".Replace("X", displayunit.ToString())
     .Replace("Z",zeroplaces.ToString())        
     ,val
    ); 
  };

  var t = TimeSpan.FromMilliseconds(milliseconds);

  //addActionToSBList(timespan property, readable display displayunit, number of zero placeholders) //Sun 24-Sep-17 8:30pm metadataconsulting.ca - Star Trek Disco
  addActionToSB(t.Days, new StringBuilder("d"),  1); 
  addActionToSB(t.Hours, new StringBuilder("h"), 1);
  addActionToSB(t.Minutes, new StringBuilder("m"), 2);
  addActionToSB(t.Seconds, new StringBuilder("s"), 2);
  addActionToSB(t.Milliseconds, new StringBuilder("ms"), 3); 
  
  return sb.ToString().TrimStart();
 }
 
 public static void Main()
 {
   Stopwatch sw = new Stopwatch();
      Console.WriteLine("Human Readable TimeSpan"); 
   sw.Start();
      string output = 111311234567L.HumanReadableTimeSpan();
      sw.Stop();
   Console.WriteLine(output); 
   Console.WriteLine(sw.ElapsedTicks+" ticks"); 
  
 }
}

Tuesday, July 30, 2019

C# Human Readable Ticks with microsecond and nanosecond units



Here's a great modern was in C Sharp code to format Stopwatch 
Elapsed Ticks to be human readable number including micro and nanoseconds places. It uses StringBuilder (for speed) and Action delegate for string format variability. 



This implementation will leave units (day, hour, ...) parts if they are zero.  Say that microseconds is 0, it will not print 0µs place to save space of output string. 

  

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System; using System.Text; 
using System.Diagnostics; 
					
public static class Program
{
	/// <summary>
        ///  Human readable elapsed time Ticks using modern Action delegate, leaving out zero parts and variable length formatting 
        ///  https://metadataconsulting.blogspot.com/2019/07/C-Sharp-Human-Readable-Ticks-with-microsecond-and-nanosecond-units.html
        /// </summary>
        /// <param name="ticks">a long type</param>
        /// <returns>Human readable units place for microseconds & nanoseconds</returns>
        public static string HumanReadableTicks(this long ticks)
        {
            if (ticks == 0) return "0 ns";

            StringBuilder SB = new StringBuilder();

            Action<long, string, int> addUnittoSB =
            (val, displayunit, zeroplaces) =>
            {
                if (val > 0) //do not print this unit place if no value for it
                {
                    SB.AppendFormat(
                            " {0:DZ}X".Replace("X", displayunit)
                            .Replace("Z", zeroplaces.ToString())
                            , val
                        );
                }
            };

            var t = TimeSpan.FromTicks(ticks);

            //addActionToSringBuilder(timespan property, readable display displayunit, number of 0 placeholders)
            addUnittoSB((long)t.Days, "d", 1); //we have to convert to long to match Action signature
            addUnittoSB((long)t.Hours, "h", 1);
            addUnittoSB((long)t.Minutes, "m", 1);
            addUnittoSB((long)t.Seconds, "s", 1);
            addUnittoSB((long)t.Milliseconds, "ms", 3); //set milliseconds to 3 zero places (long) 
            addUnittoSB((long)((int)((t.TotalMilliseconds - (int)t.TotalMilliseconds) * 1000)), "µs", 3); //TotalMilliseconds is a double and has enough decimal places for accuracy here
            addUnittoSB((long)Convert.ToUInt64((((decimal)(t.Ticks * 100) % 1000))), "ns", 3); //1 tick is one hundred nanoseconds, get thousands place

            return SB.ToString().TrimStart();
        }
	
	public static void Main()
	{
		 Stopwatch sw = new Stopwatch();
		 Console.WriteLine("Human Readable Ticks program ran for"); 
		 sw.Start();
		 System.Threading.Thread.Sleep(1345);
		 sw.Stop();
		 Console.WriteLine(sw.ElapsedTicks + " ticks or "); 
		 Console.WriteLine(string.Format("{0:N0} nanoseconds (ns).",sw.ElapsedTicks*100));
		 Console.WriteLine("Human Readable format"); 
		 Console.WriteLine(sw.ElapsedTicks.HumanReadableTicks()); 
	}
}

Monday, July 22, 2019

C Sharp Remove Whitespace common methods speed tests

Here's some common methods that are timed for removing white-space from a string.

Also see - Fastest method to remove all whitespace from Strings in .NET - CodeProject


  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System;using System.Text; using System.Diagnostics; using System.Linq; 

public static class Program
{
 public static string RemoveWhiteSpace(this string s)
 {
  char[] r = new char[s.Length]; 
  int idxr = 0; 
  for (int i = 0; i < s.Length; i++) {
   if ( !Char.IsWhiteSpace(s[i])) {
    r[idxr] = s[i];
    idxr++;
   }
  }
  return new string(r); 
 }
 
 public static string StringBuilderRemoveWhiteSpace(this string s) {
  
  StringBuilder sb = new StringBuilder();
  for (int i = 0; i < s.Length; i++) {
   if ( !Char.IsWhiteSpace(s[i])) {
    sb.Append(s[i]);
   }
    
  }
  return sb.ToString(); 
 }
 
 public static string LinqRemoveWhiteSpace(this string s) {
 
  return new string(s.ToCharArray().Where(c => !Char.IsWhiteSpace(c)).ToArray());
  
 } 
 
 //public static string NormalizeWhiteSpaceForLoop(this string input)
    public static string FastRemoveWhiteSpace(this string input)
    {
        int len = input.Length,
            index = 0,
            i = 0;
        var src = input.ToCharArray();
        //bool skip = false;
        char ch;
        for (; i < len; i++)
        {
            ch = src[i];
            switch (ch)
            {
                case '\u0020':
                case '\u00A0':
                case '\u1680':
                case '\u2000':
                case '\u2001':
                case '\u2002':
                case '\u2003':
                case '\u2004':
                case '\u2005':
                case '\u2006':
                case '\u2007':
                case '\u2008':
                case '\u2009':
                case '\u200A':
                case '\u202F':
                case '\u205F':
                case '\u3000':
                case '\u2028':
                case '\u2029':
                case '\u0009':
                case '\u000A':
                case '\u000B':
                case '\u000C':
                case '\u000D':
                case '\u0085':
                    //if (skip) continue;
                    //src[index++] = ch;
                    //skip = true;
                    continue;
                default:
                    //skip = false;
                    src[index++] = ch;
                continue;
            }
        }

        return new string(src, 0, index);
    }
 
 
 public static void Main()
 {
  Stopwatch sw = new Stopwatch(); 
  string test = "China lashes out at Hong Kong protest targeting its office Mon 22-Jul-19 10:33am"; 
  sw.Start();
  Console.WriteLine(test.RemoveWhiteSpace());
  sw.Stop(); 
  Console.WriteLine(sw.ElapsedTicks.ToString()+" ticks.");
  sw.Restart();
  Console.WriteLine(test.StringBuilderRemoveWhiteSpace());
  sw.Stop(); 
  Console.WriteLine(sw.ElapsedTicks.ToString()+" ticks.");
  sw.Restart();
  Console.WriteLine(test.LinqRemoveWhiteSpace());
  sw.Stop(); 
  Console.WriteLine(sw.ElapsedTicks.ToString()+" ticks.");
  sw.Restart();
  Console.WriteLine(test.FastRemoveWhiteSpace());
  sw.Stop(); 
  Console.WriteLine(sw.ElapsedTicks.ToString()+" ticks.");
  
 }
}

Friday, July 19, 2019

How to expand URLs in C-Sharp?





 How to expand URLs in C#?



  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System; using System.Text.RegularExpressions; using System.Net;  
using System.Web;
     
public static class Program
{
 public static string URLExpander(this string URL) {
 
      //removal ASCII and UNICODE control characters, if they exist
            string urlText = Regex.Replace(URL, @"[\u0000-\u0008|\u000B-\u000C|\u000E-\u001F|\u0080-\u009F]", "");

            if (string.IsNullOrWhiteSpace(urlText))
                return string.Empty; 

            Uri uriResult;

      //validate URL
            bool result = Uri.TryCreate(urlText, UriKind.Absolute, out uriResult)
            && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps
    || uriResult.Scheme == Uri.UriSchemeFtp || uriResult.Scheme == Uri.UriSchemeFile
       ); //or other schemes

            if (!result)
            return string.Empty;

            //https://docs.microsoft.com/en-us/dotnet/api/system.net.httpwebrequest?view=netframework-4.8
      HttpWebRequest req = null; 
            HttpWebResponse response; 
  
            try
            {
             req = (HttpWebRequest)WebRequest.Create(uriResult); 
                req.Method = "HEAD";
                req.AllowAutoRedirect = false;
                result = true; 
            }
            catch (NotSupportedException)
            {
                result = false; //add your exception handling here
                
            }
            catch (ArgumentNullException)
            {
                result = false; //add your exception handling here

            }
            catch (System.Security.SecurityException)
            {
                result = false; //add your exception handling here

            }
            catch (UriFormatException)
            {
                result = false; //add your exception handling here
   }

            if (!result)
             return string.Empty; 
            
   string redirectedURL = ""; 
            try
            {
                response =  (HttpWebResponse)req.GetResponse();
    
    //https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
    //304 Not Modified - Redirection to a previously cached result -> may not be a URL redirection
    //restrictive
    if ((int)response.StatusCode >= 300 && ((int)response.StatusCode < 400))
    {
     redirectedURL = response.Headers[HttpResponseHeader.Location]; //or url = response.Headers["Location"];
    }
    else if ((int)response.StatusCode < 300 || (int)response.StatusCode >= 400) //okay
    {
     redirectedURL = uriResult.ToString(); //set as validated URL
    }        

    result = true; 
            }       
            catch (System.Net.WebException)
            {
                result = false; 
            }
            catch (System.Net.ProtocolViolationException)
            {
                result = false; 
            }
            catch (InvalidOperationException)
            {
                result = false;                 
            }
            catch (NotSupportedException)
            {
                result = false; 
            }
            
            if (!result)
             return string.Empty;
  
   try {
             
    redirectedURL = HttpUtility.UrlDecode(redirectedURL);
   }
   catch 
            {
                return string.Empty; 
            }
  
      return redirectedURL; 
  
 }
 
 public static void Main()
 {
  string testURL = "http://bit.ly/AzureAITranslation"; string testURL2 = "https://metadataconsulting.blogspot.com"; 
  
  //sanity check 
  //if (testURL == testURL.URLExpander()) //no redirect especially for status code 304!
     
  Console.WriteLine(testURL + "\nexpands to\n" + testURL.URLExpander());
  Console.WriteLine(); 
  Console.WriteLine(testURL2 + "\nexpands to\n" + testURL2.URLExpander());
 }
}


Friday, July 12, 2019

Thursday, July 11, 2019

An extensive list of all English Quadruple Dashed Hyphenated words






Below is a list of words that separated by 4 dashes or hyphens. The list contains 4 items. 







It comes from an exhaustive list of all English Hyphenated words of 47,589 hyphenated words.

See my post for sources;  

An extensive list of all English Hyphenated words



Jack-go-to-bed-at
knock-down-and-drag-out
Mentor-on-the-Lake-Village
what-do-you-call-it

Wednesday, July 10, 2019

An extensive list of all English Triple Hyphenated words







Below is a list of words that separated by  3 dashes or hyphens. The list contains 118 words.






It comes from an exhaustive list of all English Hyphenated words of 47,589 hyphenated words.

See my post for sources;  

An extensive list of all English Hyphenated words




Alpes-de-Haute-Provence
bats-in-the-belfry
bicycle-built-for-two
bird-in-the-bush
birds-in-the-bush
blown-in-the-bottle
bras-dessus-bras-dessous
bred-in-the-bone
catch-as-catch-can
cat-o-nine-tails
cock-a-doodle-doo
cock-a-doodle-doos
cock-and-bull-story
cock-of-the-rock
cocks-of-the-rock
dai-sho-no-soroimono
devil-in-the-bush
dyed-in-the-wool
dog-in-the-manger
down-at-the-heel
down-at-the-heels
down-in-the-mouth
first-past-the-post
flame-of-the-forest
flame-of-the-woods
flames-of-the-woods
flower-of-an-hour
fore-and-aft-rigged
get-up-and-get
get-up-and-go
gill-over-the-ground
glory-of-the-snow
glory-of-the-snows
glory-of-the-sun
glory-of-the-suns
go-as-you-please
hail-fellow-well-met
hide-and-go-seek
high-muck-a-muck
hop-o-my-thumb
how-do-ye-do
how-do-you-do
jack-at-a-pinch
jack-by-the-hedge
Jack-go-to-bed
jack-in-a-box
jack-in-a-boxes
jack-in-the-box
jack-in-the-boxes
jack-in-the-green
jack-in-the-pulpit
jack-in-the-pulpits
jack-of-all-trades
jacks-of-all-trades
Johnny-on-the-spot
king-of-the-herrings
king-of-the-salmon
knock-down-and-drag
knock-down-and-drag
knock-down-drag-out
ladies-of-the-night
lady-of-the-night
love-in-a-mist
man-of-the-earths
men-of-the-earth
Mentor-on-the-Lake
middle-of-the-road
middle-of-the-roader
mind-your-own-business
never-to-be-equaled
nievie-nievie-nick-nack
no-deposit-no-return
on-again-off-again
one-and-a-half
o-o-a-a
out-of-the-common
out-of-the-way
out-of-the-world
pay-as-you-go
queen-of-the-meadow
queen-of-the-prairie
run-of-the-mill
run-of-the-mine
Saint-Maur-des-Foss
snow-on-the-mountain
spur-off-the-moment
spur-of-the-moment
state-of-the-art
stick-at-it-ive
stick-in-the-mud
stick-to-it-iveness
straight-from-the-shoulder
straight-up-and-down
Sunday-go-to-meeting
Sunday-go-to-meetings
theater-in-the-round
theatre-in-the-round
three-and-a-halfpenny
toad-in-the-hole
tol-lol-de-rol
Tom-come-tickle-me
touch-me-not-ish
trick-o-the-loop
two-for-a-cent
two-for-a-penny
un-come-at-able
un-come-at-ableness
un-come-at-ably
un-get-at-able
un-get-at-ableness
up-to-the-minute
wag-on-the-wall
what-do-you-call
what-you-call-it
what-you-may-call
will-o-the-wisp
will-with-the-wisp
Wu-lu-mu-ch

An extensive list of all English Double Hyphenated words


Below is a extensive list of words that separated by  2 dashes or hyphens. 
The list contains 1089 words.

It comes from an exhaustive list of all English Hyphenated words 47,589 hyphenated words. 






See my post for sources; 

An extensive list of all English Hyphenated words



A-and-R
Abd-el-Kadir
Abd-el-Krim
ach-y-fi
a-cock-bill
a-cock-horse
across-the-board
Adam-and-Eve
a-gore-blood
a-high-lone
aid-de-camp
aide-de-camp
aide-de-campship
aides-de-camp
aids-de-camp
air-to-air
air-to-ground
air-to-surface
Aix-en-Provence
Aix-la-Chapelle
Aix-les-Bains
Alan-a-dale
Alice-in-Wonderland
all-a-mort
Allan-a-Dale
all-expenses-paid
allez-vous-en
all-flower-water
all-in-one
all-or-none
Alpes-de-Haute
alto-cumulus-castellatus
ambassador-at-large
ambassadors-at-large
angels-on-horseback
anti-hog-cholera
anti-laissez-faire
anti-mony-yellow
anti-open-shop
anti-pre-existentiary
arm-in-arm
around-the-clock
artist-in-residence
Ashton-under-Lyne
attorney-at-law
attorney-in-fact
attorneys-at-law
attorneys-in-fact
auto-da-f
auto-da-fe
baby-blue-eyes
bachelor-at-arms
bachelors-at-arms
back-and-forth
back-to-back
back-to-front
bacon-and-eggs
bar-and-grill
Bar-le-duc
barrister-at-law
Barrow-in-Furness
basket-of-gold
bats-in-the
Beach-la-Mar
Beche-de-Mer
beche-le-mar
bed-sitting-room
beggar-my-neighbor
beggar-my-neighbour
berry-on-bone
Berwick-upon-Tweed
Bexhill-on-Sea
by-and-by
by-and-large
Biche-la-mar
bicycle-built-for
bid-a-bid
by-doingby-drinking
by-your-leave
bill-and-cooers
bird-in-the
birds-in-the
bit-by-bit
by-the-bye
by-the-way
black-and-blue
black-and-tan
black-and-white
black-a-viced
black-a-visaged
black-a-vised
Blandy-les-Tours
blind-your-eyes
blood-and-guts
blood-and-thunder
blow-by-blow
blown-in-the
blue-yellow-blind
board-and-roomer
board-and-shingle
boggle-dy-botch
boy-meets-girl
Bois-le-Duc
bonheur-du-jour
bonheurs-du-jour
boom-and-bust
bord-and-pillar
Bouches-du-Rh
Boule-de-suif
Boulogne-sur-Mer
Boulogne-sur-Seine
bras-dessus-bras
bread-and-butter
bred-in-the
bric-a-brac
bric-a-brackery
bride-to-be
brother-in-arms
brother-in-law
brothers-in-law
bubble-and-squeak
buck-and-wing
burn-the-wind
Burton-upon-Trent
but-and-ben
buts-and-bens
butter-and-eggs
cap-a-pie
cap-in-hand
carte-de-visite
cash-and-carry
cast-iron-plant
cast-me-down
cat-a-mountain
cat-and-dog
cat-and-doggish
catch-as-catch
cat-o-nine
cause-and-effect
Cel-o-Glass
centimeter-gram-second
centimetre-gramme-second
centimetre-gram-second
cha-cha-cha
Chalons-sur-Marne
Chalon-sur-Sa
Champigny-sur-Marne
char-a-banc
char-a-bancs
charge-a-plate
Chateauneuf-du-Pape
Chaumont-en-Bassigny
cheek-by-jowl
chest-on-chest
cheval-de-frise
chevaux-de-frise
Chlons-sur-Marne
chock-a-block
christ-cross-row
chuck-a-luck
chug-a-lug
chute-the-chute
chute-the-chutes
C-in-C
Clichy-la-Garenne
clish-ma-claver
cloak-and-dagger
cloak-and-suiter
cloak-and-sword
close-at-hand
cloth-of-gold
Cloud-cuckoo-land
coach-and-four
cock-a-doodle
cock-a-doodle
cock-a-doodle
cock-a-doodle
cock-a-doodle
cock-a-hoop
cock-a-hooping
cock-a-hoopish
cock-a-hoopness
cock-a-leekie
cock-and-bull
cock-and-bull
cock-and-pinch
cock-as-hoop
cock-a-whoop
cock-of-the
cocks-of-the
codlins-and-cream
collar-to-collar
come-all-ye
come-at-ability
come-at-able
come-at-ableness
come-by-chance
comrade-in-arms
cone-in-cone
congressman-at-large
congressmen-at-large
cornet-a-pistons
counselor-at-law
counselors-at-law
country-and-western
courtship-and-matrimony
Cousance-les-Forges
cousin-in-law
crack-the-whip
crag-and-tail
crawl-a-bottom
Croton-on-Hudson
crown-of-jewels
crown-of-thorns
cul-de-four
cul-de-lampe
cul-de-sac
cumu-cirro-stratus
cumulo-cirro-stratus
cut-and-cover
cut-and-dry
cut-and-dried
cut-and-try
daddy-long-legs
day-and-night
day-by-day
dai-sho-no
day-to-day
Dar-es-Salaam
Dasht-i-Kavir
Dasht-i-Lut
daughter-in-law
daughters-in-law
dead-and-alive
deaf-and-dumb
death-come-quickly
devil-in-the
devil-may-care
devil-may-careness
devils-on-horseback
s-walking-stick
dyed-in-the
dime-a-dozen
ding-a-ling
doch-an-dorrach
doch-an-dorris
doch-an-dorroch
dog-eat-dog
dog-in-the
do-it-yourself
do-it-yourselfer
Domremy-la-Pucelle
Domrmy-la-Pucelle
doon-head-clock
do-or-die
door-to-door
do-re-mi
dos-a-dos
do-si-do
double-or-nothing
down-and-out
down-and-outer
down-at-heel
down-at-heels
downat-the-heel
down-at-the
down-at-the
down-in-the
down-the-line
down-to-date
down-to-earth
down-to-earthness
drap-de-berry
dry-as-dust
Dutch-ware-blue
eau-de-vie
editor-in-chief
eyeball-to-eyeball
El-beth-el
eleven-oclock-lady
end-to-end
Entre-Deux-Mers
equi-gram-molar
Eure-et-Loir
Evian-les-Bains
examine-in-chief
face-to-face
fare-ye-well
fare-you-well
fare-thee-well
farewell-to-spring
father-in-law
father-long-legs
fathers-in-law
feast-or-famine
fee-faw-fum
felo-de-se
felones-de-se
felos-de-se
fer-de-lance
fer-de-moline
ferro-carbon-titanium
fiddle-de-dee
fine-tooth-comb
finger-and-toe
fire-and-brimstone
first-past-the
fish-and-chips
five-and-dime
five-and-ten
five-by-five
flame-of-the
flame-of-the
flames-of-the
fleur-de-lis
fleur-de-lys
fleurs-de-lis
fleurs-de-lys
fly-by-night
flower-de-luce
flower-of-an
flower-of-Jove
flowers-of-Jove
follow-my-leader
foot-pound-second
fore-and-aft
fore-and-after
fore-and-aft
forget-me-not
Fort-de-France
four-a-cat
four-year-old
four-year-older
four-in-hand
four-stroke-cycle
four-times-accented
free-for-all
full-to-full
Gay-Pay-Oo
garde-du-corps
gentleman-at-arms
gentlemen-at-arms
get-at-ability
get-at-able
get-at-ableness
get-up-and
get-up-and
giddy-go-round
gill-over-the
give-and-take
glory-of-the
glory-of-the
glory-of-the
glory-of-the
go-as-you
god-a-mercy
gold-of-pleasure
Go-no-further
good-bye-summer
good-for-naught
good-for-nothing
good-for-nothingness
Good-King-Henry
Good-King-Henries
good-morning-spring
go-to-itiveness
go-to-meeting
government-in-exile
grace-and-favor
grace-and-favour
grant-in-aid
grants-in-aid
grass-of-Parnassus
gris-de-lin
ground-to-air
ground-to-ground
hack-me-tack
Ha-erh-pin
hay-de-guy
hail-fellow-well
Hay-on-Wye
half-a-crown
half-a-dollar
half-and-half
half-seas-over
hall-of-famer
hand-in-glove
hand-in-hand
hand-me-down
hand-me-downs
hand-to-hand
hand-to-mouth
happy-go-lucky
happy-go-luckyism
happy-go-luckiness
harbinger-of-spring
harbingers-of-spring
hard-and-fast
hard-and-fastness
hard-of-hearing
Hastings-on-Hudson
hat-in-hand
Hauts-de-Seine
head-over-heels
hearts-and-flowers
heart-to-heart
heavier-than-air
he-cabbage-tree
heel-and-toe
height-to-paper
heir-at-law
hell-for-leather
hen-and-chickens
Henley-on-Thames
hens-and-chickens
hide-and-go
hide-and-seek
high-and-mighty
high-and-mightiness
high-low-jack
high-muck-a
high-muck-a
high-muckety-muck
hit-and-miss
hit-and-run
hit-or-miss
hit-or-missness
hob-and-nob
hole-and-comer
hole-and-corner
hole-in-corner
holier-than-thou
homo-hetero-analysis
honest-to-God
hook-and-ladder
hop-o-my
horse-and-buggy
hose-in-hose
hot-air-heat
hot-air-heated
hot-water-heat
hot-water-heated
Houghton-le-Spring
house-to-house
how-de-do
how-do-ye
how-do-ye
how-do-you
Hsin-hai-lien
hug-me-tight
husband-to-be
yard-of-ale
ya-ta-ta
yea-and-nay
yea-and-nayish
yellowish-green-yellow
yellowish-red-yellow
Ile-de-France
ill-at-ease
Ille-et-Vilaine
in-and-in
in-and-out
in-and-outer
in-co-ordinate
in-co-ordinated
in-co-ordination
Indre-et-Loire
in-the-wool
in-to-out
yo-heave-ho
yo-ho-ho
you-be-damned
you-be-damnedness
you-know-what
you-know-who
Issy-les-Molineux
Ivry-la-Bataille
jack-a-dandy
jack-a-dandies
jack-a-dandyism
Jack-a-lent
jack-at-a
jack-by-the
Jack-go-to
bed-at-noon
jack-in-a
jack-in-a
jack-in-office
jack-in-the
jack-in-the
jack-in-the
jack-in-the
jack-in-the
jack-of-all
jack-o-lantern
jacks-of-all
Jack-the-rags
jane-of-apes
jib-o-jib
john-a-nokes
john-a-stiles
Johnny-come-lately
Johnny-come-latelies
Johnnie-come-lately
Johnnies-come-lately
Johnny-jump-up
Johnny-on-the
Juan-les-Pins
jumping-off-place
Karl-Marx-Stadt
keen-o-peachy
kilovolt-ampere-hour
Kindu-Port-Empain
king-of-arms
king-of-the
king-of-the
kings-of-arms
Kingston-upon-Hull
kiss-me-quick
knock-down-and
knock-down-and
knock-down-drag
knock-me-down
know-it-all
Koh-i-noor
komma-ichi-da
la-de-da
la-di-da
ladies-in-waiting
ladies-of-the
lady-in-waiting
lady-of-the
lah-di-dah
leg-of-mutton
life-and-death
life-or-death
lighter-than-air
light-of-love
lin-lan-lone
little-by-little
live-in-idleness
load-water-line
lock-a-daisy
Loir-et-Cher
long-drawn-out
Lons-le-Saunier
loop-the-loop
lord-in-waiting
lords-and-ladies
lords-in-waiting
Lot-et-Garonne
love-in-a
love-in-idleness
love-lies-bleeding
made-to-measure
made-to-order
maid-in-waiting
maids-in-waiting
main-de-fer
Maine-et-Loire
make-or-break
man-about-town
man-at-arms
man-of-the
man-of-war
man-to-man
marvel-of-Peru
master-at-arms
masters-at-arms
matter-of-course
matter-of-fact
matter-of-factly
matter-of-factness
men-at-arms
men-of-the
men-of-war
Mentor-on-the
merry-go-round
meter-candle-second
meter-kilogram-second
metre-kilogram-second
Meurthe-et-Moselle
middle-of-the
middle-of-the
might-have-been
Mi-le-fo
milk-and-water
milk-and-watery
milk-and-wateriness
milk-and-waterish
milk-and-waterism
mind-your-own
mise-en-scene
mont-de-piete
mont-de-pit
Mont-Saint-Michel
mother-in-law
mother-of-pearl
mother-of-thyme
mother-of-thymes
mother-of-thousands
mothers-in-law
mouth-to-mouth
mumble-the-peg
near-at-hand
needle-and-thread
neer-do-well
er-do-well
Neuilly-sur-Seine
Never-Never-land
never-say-die
never-to-be
Newark-on-Trent
Newcastle-under-Lyme
Newcastle-upon-Tyne
nievie-nievie-nick
nitro-hydro-carbon
no-deposit-no
noli-me-tangere
non-co-operate
non-co-operation
non-co-operationist
non-co-operative
non-co-operator
non-co-ordination
none-so-pretty
none-so-pretties
Non-indo-european
non-profit-making
no-par-value
north-north-east
north-north-west
noughts-and-crosses
now-a-day
now-a-days
ns-a-vis
Nuits-Saint-Georges
Nuits-St-Georges
ochr-el-guerche
odd-come-short
odd-come-shortly
odd-me-dod
oeil-de-boeuf
oeils-de-boeuf
off-off-Broadway
off-the-cuff
off-the-face
off-the-peg
off-the-record
off-the-wall
of-the-moment
on-again-off
one-a-cat
one-and-a
one-by-one
one-hundred-fifty
one-hundred-percenter
one-hundred-percentism
one-to-one
One-two-three
o-o-a
oo-la-la
open-and-shut
ouster-le-main
out-and-out
out-and-outer
out-of-bounds
out-of-center
out-of-course
out-of-date
out-of-dateness
out-of-door
out-of-doors
out-of-fashion
out-of-focus
out-of-hand
out-of-humor
out-of-joint
out-of-line
out-of-office
out-of-order
out-of-place
out-of-plumb
out-of-pocket
out-of-print
out-of-reach
out-of-school
out-of-season
out-of-stater
out-of-stock
out-of-the
out-of-the
out-of-the
out-of-town
out-of-towner
out-of-townish
out-of-tune
out-of-tunish
out-of-turn
out-of-vogue
over-the-counter
pay-as-you
Para-thor-mone
parent-in-law
Pas-de-Calais
pat-a-cake
paulo-post-future
peg-a-lantern
pen-and-ink
penny-a-line
penny-a-liner
pepper-and-salt
person-to-person
pick-a-back
pick-me-up
pick-up-sticks
pied-a-terre
pied-de-biche
pillar-and-breast
pit-a-pat
pitch-and-putt
pitch-and-run
pitch-and-toss
play-by-play
pneumato-hydato-genetic
poet-in-residence
point-to-point
pom-pom-pullaway
portal-to-portal
Port-au-Prince
Port-of-Spain
Post-basket-maker
pot-au-feu
poult-de-soie
pre-free-trade
pretty-by-night
pride-of-India
pro-co-operation
profit-and-loss
pro-pre-existentiary
Proto-Indo-European
pro-vice-chancellor
put-and-take
queen-of-the
queen-of-the
rack-and-pinion
rank-and-filer
ranz-des-vaches
rat-a-tat
rat-tat-tat
reach-me-down
reach-me-downs
ready-for-wear
ready-to-wear
re-coilre-collect
re-co-operate
re-co-operation
reel-to-reel
relative-in-law
relatives-in-law
rez-de-chaussee
rhythm-and-blues
Richmond-upon-Thames
right-about-face
right-of-way
rights-of-way
ring-a-lievio
ring-a-rosy
robe-de-chambre
robes-de-chambre
rock-and-roll
room-and-pillar
root-mean-square
rory-cum-tory
rose-a-ruby
Rostov-on-Don
rough-and-ready
rough-and-readiness
rough-and-tumble
round-about-face
round-the-clock
row-de-dow
row-dow-dow
rub-a-dub
rude-spokenrude-spun
run-of-mill
run-of-mine
run-of-paper
run-of-the
run-of-the
sac-a-lait
sad-a-vised
Saint-Maur-des
salt-and-pepper
sang-de-boeuf
Sat-chit-ananda
Sat-cit-ananda
sauve-qui-peut
Saxe-Coburg-Gotha
Saxe-Weimar-Eisenach
second-in-command
Seine-et-Marne
Seine-et-Oise
Seine-Saint-Denis
semi-armor-piercing
Serb-croat-slovene
sergeant-at-arms
sergeant-at-law
serjeant-at-law
Shatt-al-Arab
ship-of-war
ship-to-shore
shoot-the-chutes
side-by-side
side-by-sideness
Sidi-bel-Abb
sine-qua-nonical
sine-qua-noniness
Siraj-ud-daula
sister-in-law
six-by-six
six-year-old
six-o-six
six-three-three
sleep-at-noon
sleight-of-hand
slug-a-bed
smash-and-grab
snick-and-snee
snick-a-snee
snip-snap-snorum
snow-in-summer
snow-on-the
so-and-so
so-and-sos
song-and-dance
son-in-law
son-in-lawship
sons-in-law
sops-in-wine
sore-pressedsore-taxed
sound-on-film
soup-and-fish
Southend-on-Sea
south-south-east
south-south-west
spick-and-span
spick-and-spandy
spick-and-spanness
spick-span-new
spit-and-polish
spur-off-the
spur-of-the
stay-at-home
stay-a-while
star-of-Bethlehem
star-of-Jerusalem
stars-of-Bethlehem
stars-of-Jerusalem
state-of-the
station-to-station
step-and-repeat
step-by-step
stick-at-it
stick-at-itive
stick-at-it
stick-at-itiveness
stick-at-nothing
stick-in-the
stick-to-itive
stick-to-itively
stick-to-itiveness
stick-to-it
stock-in-trade
Stockton-on-Tees
Stoke-on-Trent
Stoke-upon-Trent
straight-from-the
straight-line-frequency
straight-up-and
Stratford-on-Avon
Stratford-upon-Avon
stream-of-consciousness
strike-a-light
sub-machine-gun
such-and-such
Sunbury-on-Thames
Sunday-go-to
Sunday-go-to
surface-to-air
surface-to-surface
surface-to-underwater
Sutton-in-Ashfield
sweet-and-sour
tae-kwan-do
tam-o-shanter
tam-o-shantered
tap-tap-tap
tar-and-feathering
Tarn-et-Garonne
tat-tat-tat
tea-of-heaven
tenant-in-chief
ten-a-penny
ten-twenty-thirty
terre-a-terreishly
tete-a-tete
thank-you-maam
thank-you-ma
that-a-way
theater-in-the
theatre-in-the
then-a-days
thing-in-itself
thing-it-self
things-in-themselves
this-a-way
this-way-ward
thou-shalt-not
thread-the-needle
three-a-cat
three-and-a
three-by-four
three-year-old
three-in-hand
three-in-one
three-quarter-bred
through-and-through
thumb-and-finger
tick-a-tick
ticket-of-leave
ticket-of-leaver
tick-tack-toe
tick-tack-too
tic-tac-toe
tie-and-dye
ting-a-ling
tink-a-tink
tip-and-run
Tir-na-n
tit-tat-toe
toad-in-the
to-and-fro
to-and-fros
to-and-ko
tol-de-rol
tol-lol-de
tol-lol-ish
Tom-and-jerry
Tom-and-jerryism
Tom-come-tickle
top-over-tail
touch-and-go
touch-in-goal
touch-me-not
touch-me-not
tous-les-mois
track-and-field
tra-la-la
trente-et-quarante
trial-and-error
trick-or-treat
trick-or-treater
trick-o-the
tried-and-trueness
tripe-de-roche
trou-de-coup
trou-de-loup
true-to-lifeness
tug-of-war
tug-of-warring
tum-ti-tum
twelve-year-old
twenty-four-hour
twice-re-elected
two-a-cat
two-by-four
two-for-a
two-for-a
two-year-old
two-stroke-cycle
uncome-at-able
un-come-at
un-come-at
un-come-at
un-co-operating
un-co-operative
un-co-ordinate
un-co-ordinated
under-the-counter
under-the-table
un-first-class
un-free-trade
unget-at-able
un-get-at
un-get-at
United-states-man
un-panic-stricken
un-thought-of
up-a-daisy
up-and-coming
up-and-comingness
up-and-doing
up-and-down
up-and-downy
up-and-downish
up-and-downishness
up-and-downness
up-and-over
up-and-under
up-and-up
up-see-daisy
up-to-date
up-to-dately
up-to-dateness
up-to-datish
up-to-datishness
up-to-the
va-et-vien
Val-de-Marne
valet-de-chambre
valet-de-place
very-high-frequency
Vic-en-Bigorre
vingt-et-un
Viollet-le-Duc
V-I-P
vis-a-ns
vis-a-vis
vis-a-visness
vitro-di-trina
vol-au-vent
volt-ohm-milliammeter
wag-on-the
wait-a-bit
wall-to-wall
wanted-right-hand
wash-and-wear
Watch-and-warder
well-brought-up
well-cared-for
well-set-up
well-thought-of
well-thought-out
well-to-do
well-turned-out
well-worked-out
west-north-west
Weston-super-Mare
west-south-west
wet-my-lip
ye-call-it
you-call-it
what-do-you
what-you-call
what-you-may
what-you-may
what-is-it
whats-her-name
s-her-name
s-his-face
whats-his-name
s-his-name
whats-its-name
s-its-name
whip-poor-will
whip-tom-kelly
who-does-what
whole-and-half
whole-or-none
whoop-de-do
whoop-de-doo
whoop-de-dos
wide-a-wake
wife-to-be
wild-and-woolly
will-o-the
will-with-the
word-for-word
word-of-mouth
work-and-tumble
work-and-turn
work-and-twist
work-and-whirl
world-without-end
would-have-been
writer-in-residence
Wu-lu-mu
X-ray-proof

Monday, July 8, 2019

An extensive list of all English Hyphenated words

Here's an exhaustive list of all English Hyphenated words, available as a  zip file for download. 






It contains 47,589 hyphenated words.






Maximum amount of  hyphens in a word 5 and is "Jack-go-to-bed-at-noon". 
Longest  hyphenated word "tetrabromo-phenolsulfonephthalein" at 33 characters.

Sample of file contents; 

a-a
A-and
A-and-R
A-axes
A-axis
Abd-el
Abd-el-Kadir
Abd-el-Krim
abdomino-uterotomy
Abdul-Aziz
Abdul-baha
a-be
A-blast
able-bodied
able-bodiedism
able-bodiedness
able-bodism
able-minded
able-mindedness
A-bomb

Break down of list

Dowload:

http://bit.ly/HyphenatedWordsZip


Note: Using bit.ly only to track number of downloads. I am curious to see the interest in this file, since I could not find it anywhere except 1 paid site!

Sources :


  1. https://github.com/dwyl/english-words
  2. http://wordnetcode.princeton.edu/wn3.1.dict.tar.gz
  3. https://www.btb.termiumplus.gc.ca/tcdnstyl-chap?lang=eng&lettr=chapsect2&info0=2
  4. http://wordlist.aspell.net/ 
  5. https://public.oed.com/updates/new-words-list-march-2019/  add hee-haw, but was in above compilation already, discredit this source

If you have any other good sources, please leave your suggestion.