Abit of a precursor;
It starts at Genesis 38, directly after the chapter where Jacob's son Joseph (the technicolour dreamcoat one) was about to be killed/left for dead by his jealous brothers, before they spot some Midianite merchants when Judah (one of the jealous brothers) suggests they make a profit off their brothers removal instead, selling him to the Midianites for twenty pieces of silver. After which the Midianites take Joseph to Egypt (eventually selling him to a bloke called Potiphar, one of the pharoh's officers and captain of the guard.) and the brothers kill a goat kid and use its blood to soak Josephs coat to show to their father Jacob who upon believing the story of his sons demise goes into mourning: 37:34 And Jacob rent his clothes , and put sack-cloth upon his loins, and mourned for his son many days.
Back to Chapter 38, the point of discussion;
(Note that some of the commas have spaces after them before the next word and some do not, these were put in as they appeared in the copy I have, not sure if they're intentional or the way the press laid them out during print.)
38:1 And it came to pass at that time, that Judah went down from his bretheren, and turned in to a certain Adullamite, whose name was Hirah.
38:2 And Judah saw there a certain Canaanite, whose name was Shuah; and he took her and went in unto her.
38:3 And she conceived, and bare a son; and he called his name Er.
38:4 And she conceived again,and bare a son; and he called his name Onan.
38:5 And she yet again conceived, and bare a son; and she called his name Shelah: and he was at Chezib,when she bare him.
38:6 And Judah took a wife for Er his first-born, whose name was Tamar.
38:7 And Er,Judah's firstborn, was wicked in the sight of the Lord; and the Lord slew him.
38:8 And Judah said unto Onan,Go in unto thy brother's wife,and marry her,and raise up seed to thy brother.
38:9 And Onan knew that the seed should not be his; and it came to pass when he went in unto his brother's wife, that he spilled it on the ground, lest that he should give seed to his brother.
38:10 And the thing which he did displeased the Lord: wherefore he slew him also.
38:11 Then said Judah to Tamar his daughter in law,Remain a widow at thy father's house,till Shelah my son be grown: for he said, Lest preadventure he die also, as his bretheren did. And Tamar went and dwelt in her father's house.
38:12 And in process of time the daughter of Shuah Judah's wife died; and Judah was comforted, and went up unto his sheep-shearers to Timnath, he and his friend Hirah the Adullamite.
38:13 And it was told Tamar, saying, Behold thy father in law goeth up to Timnath to shear his sheep.
38:14 And she put her widow's garments off from her, and covered her with a vail, and wrapped herself and sat in an open place, which is by the way to Timnath; for she saw that Shelah was grown, and she was not given unto him to wife.
38:15 When Judah saw her, he thought her to be an harlot; because she had covered her face.
38:16 And he turned unto her by the way, and said,Go to,I pray thee, let me come in unto thee; (for he knew not that she was his daughter in law.) And she said, What wilt thou give me, that thou mayest come in unto me?
38:17 And he said, I will send thee a kid from the flock. And she said, wilt thou give me a pledge, till thou send it?
38:18 And he said, What pledges shall I give thee? And she said, Thy signet, and thy bracelets,and thy staff that is in thine hand. And he gave it her, and came in unto her, and she conceived by him.
38:19 And she arose,and went away,and laid by her vail from her, and put on the garments of her widowhood.
38:20 And Judah sent the kid by the hand of his friend the Adullamite, to receive his pledge from the woman's hand: but he found her not.
38:21 The he asked the men of the place, saying, Where is the harlot,that was openly by the way side? And they said, There was no harlot in this place.
38:22 And he returned to Judah, and said, I cannot find her; and also the men of the place said, that there was no harlot in this place.
38:23 And Judah said, Let her take it to her, lest we be shamed: behold, I sent this kid, and thou hast not found her.
38:24 And it came to pass about three months after,that it was told Judah,saying, Tamar thy daughter in law hath played the harlot; and also, behold, she is with child by whoredom. And Judah said, Bring her forth, and let her be burnt.
38:25 When she was brought forth,she sent to her father in law,saying,By the man, whose these are,am I with child: and she said,Discern, I pray thee, whose are these, the signet and bracelets and staff.
38:26 And Judah acknowledged them, and said, She hath been more righteous than I; because I gave her not to Shelah my son. And he knew her again no more.
38:27 And it came to pass in the time of her travail,that,behold twins were in her womb.
38:28 And it came to pass, when she travailed,that the one put out his hand: and the midwife took and bound upon his hand a scarlet thread,saying,This came out first.
38:29 And it came to pass, as he drew back his hand, that, behold, his brother came out: and she said,How hast thou broken forth? this breach be upon thee: therefore his name was called Pharez.
38:30 And afterward came out his brother, that had the scarlet thread upon his hand: and his name was called Zarah.
That concludes chapter 38 of the book of Genesis.