Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me convert flat-file please! 1

Status
Not open for further replies.

webmigit

Programmer
Joined
Aug 3, 2001
Messages
2,027
Location
US
This one is beyond me and I'm hoping regular expressions will save me alot of time but I'm very weak at regular expressions...

Below is the first four entries from a file containing 755 devotionals..

Can someone please help me write the code I need to write each entry into a file named #book#-#chapter#-#verse#.vinc or whatever? And here's where the RE's come in.. I need to name it by the verse its tabbed with.. each verse refference is tagged with -- at the beginning and ends with a number..

Thanks in advance for ANY help..
Tony Hicks
--------
<a name=&quot;01/04/AM&quot;></a>
<p>
&quot;Grow in grace, and in the knowledge of our Lord and Saviour
Jesus Christ.&quot;
--2 Peter 3:18
<p>
&quot;Grow in grace&quot;--not in one grace only, but in <i>all</i> grace. Grow in that root-grace, <i>faith.</i> Believe the promises more firmly than you have done. Let faith increase in fulness, constancy, simplicity. Grow also in <i>love.</i> Ask that your love may become extended, more intense, more practical, influencing every thought, word, and deed. Grow likewise in <i>humility.</i> Seek
to lie very low, and know more of your own nothingness. As you grow <i>downward</i> in humility, seek also to grow <i>upward</i>--having nearer approaches to God in prayer and more intimate fellowship with Jesus. May God the Holy Spirit enable you to &quot;<i>grow in the knowledge of our Lord and Saviour.</i>&quot; He who grows not in the knowledge of Jesus, refuses to be blessed. To know Him is &quot;life eternal,&quot; and to advance in the knowledge of Him is to increase in happiness. He who does not long to know more of Christ, knows nothing of Him yet. Whoever hath sipped this wine will thirst for more, for although Christ doth satisfy, yet it is such a satisfaction, that the appetite is not cloyed, but whetted. If you know the love of Jesus--as the hart panteth for the water-brooks, so will you pant after deeper draughts of His love. If you do not desire to know Him better, then you love Him not, for love always cries, &quot;Nearer, nearer.&quot; Absence from Christ is hell; but the presence of Jesus is heaven. Rest not then content without an increasing acquaintance with Jesus. Seek to know more of Him in His divine nature, in His human relationship, in His finished work, in His death, in His
resurrection, in His present glorious intercession, and in His future royal advent. Abide hard by the Cross, and search the mystery of His wounds. An increase of love to Jesus, and a more perfect apprehension of His love to us is one of the best tests of growth in grace.
<p>
<a name=&quot;01/05/AM&quot;></a>
<p>
&quot;And God saw the light, that it was good: and God divided the light from the darkness.&quot;
--Genesis 1:4
<p>
Light might well be good since it sprang from that fiat of goodness, &quot;Let there be light.&quot; We who enjoy it should be more grateful for it than we are, and see more of God in it and by it. Light <i>physical</i> is said by Solomon to be sweet, but <i>gospel</i> light is infinitely more precious, for it reveals eternal things, and ministers to our immortal natures. When the Holy Spirit gives us <i>spiritual</i> light, and opens our eyes to behold the glory of God in the face of Jesus Christ, we behold sin in its true colours, and ourselves in our real position; we
see the Most Holy God as He reveals Himself, the plan of mercy as He propounds it, and the world to come as the Word describes it. Spiritual light has many beams and prismatic colours, but whether they be knowledge, joy, holiness, or life, all are divinely good. If the light received be thus good, what must the <i>essential</i> light be, and how glorious must be the place where He reveals Himself. O Lord, since light is so good, give us more of it, and more of Thyself, the true light.
<p> No sooner is there a good thing in the world, than <i>a
division is necessary.</i> Light and darkness have no communion; God has divided them, let us not confound them. Sons of light must not have fellowship with deeds, doctrines, or deceits of darkness. The children of the day must be sober, honest, and bold in their Lord's work, leaving the works of darkness to those who shall dwell in it for ever. Our Churches should by discipline divide the light from the darkness, and we should by our distinct separation from the world do the same. In judgment, in action, in hearing, in teaching, in association, we must
discern between the precious and the vile, and maintain the
great distinction which the Lord made upon the world's first
day. O Lord Jesus, be Thou our light throughout the whole of
this day, for Thy light is the light of men.
<p>
<a name=&quot;01/06/AM&quot;></a>
<p>
&quot;Casting all your care upon Him; for He careth for you.&quot;
--1 Peter 5:7
<p>
It is a happy way of soothing sorrow when we can feel--&quot;HE
careth for me.&quot; Christian! do not dishonour religion by always wearing a brow of care; come, cast your burden upon your Lord. You are staggering beneath a weight which your Father would not feel. What seems to you a crushing burden, would be to Him but as the small dust of the balance. Nothing is so sweet as to <pre>
<p>
&quot;Lie passive in God's hands,
And know no will but His.&quot;
<p>
</pre>
O child of suffering, be thou patient; God has not passed thee over in His providence. He who is the feeder of sparrows, will also furnish you with what you need. Sit not down in despair; hope on, hope ever. Take up the arms of faith against a sea of trouble, and your opposition shall yet end your distresses. <i>There is</i> One who careth for you. His eye is fixed on you, His heart beats with pity for your woe, and his hand omnipotent shall yet bring you the needed help. The darkest cloud shall scatter itself in showers of mercy. The blackest gloom shall give place to the morning. He, if thou art one of His family, will bind up thy wounds, and heal thy broken heart. Doubt not His grace because of thy tribulation, but believe that He loveth
thee as much in seasons of trouble as in times of happiness.
What a serene and quiet life might you lead if you would leave providing to the God of providence! With a little oil in the cruse, and a handful of meal in the barrel, Elijah outlived the famine, and you will do the same. If God cares for you, why need you care too? Can you trust Him for your soul, and not for your body? He has never refused to bear your burdens, He has never fainted under their weight. Come, then, soul! have done with fretful care, and leave all thy concerns in the hand of a gracious God.
<p>
<a name=&quot;01/07/AM&quot;></a>
<p>
&quot;For me to live is Christ.&quot;
--Philippians 1:21
<p>
The believer did not always live to Christ. He began to do so when God the Holy Spirit convinced him of sin, and when by grace he was brought to see the dying Saviour making a propitiation for his guilt. From the moment of the new and celestial birth the man begins to live to Christ. Jesus is to believers the one pearl of great price, for whom we are willing to part with all that we have. He has so completely won our love, that it beats alone for Him; to His glory we would live, and in defence of His gospel we would die; He is the pattern of our life, and the model after which we would sculpture our character. Paul's words
mean more than most men think; they imply that the <i>aim and end of his life</i> was Christ--nay, his life itself was Jesus. In the words of an ancient saint, he did eat, and drink, and sleep eternal life. Jesus was his very breath, the soul of his soul, the heart of his heart, the life of his life. Can you say, as a professing Christian, that you live up to this idea? Can you honestly say that for you to live is Christ? Your business--are you doing it <i>for Christ</i>? Is it not done for self-aggrandizement and for family advantage? Do you ask, &quot;Is that a mean reason?&quot; For the <i>Christian</i> it is. He professes to live for Christ; how can he live for another object without
committing a spiritual adultery? Many there are who carry out this principle in some measure; but who is there that dare say that he hath lived wholly for Christ as the apostle did? Yet, this alone is the true life of a Christian--its source, its sustenance, its fashion, its end, all gathered up in one word--Christ Jesus. Lord, accept me; I here present myself, praying to live only in Thee and to Thee. Let me be as the bullock which stands between the plough and the altar, to work or to be sacrificed; and let my motto be, &quot;Ready for either.&quot;
<p>
-------
 
Try this:

<!--- Read Text File --->
<CFFILE FILE=&quot;c:\folders\dev.txt&quot; ACTION=&quot;READ&quot; VARIABLE=&quot;vDev&quot;>

<!--- Set Deliminator to convert text file to list --->
<CFSET vDelim = &quot;|&quot;>

<!--- Put the deliminator in front of every &quot;<a name&quot; --->
<CFSET vDev = ReplaceNoCase(VARIABLES.vDev, &quot;<a name&quot;, VARIABLES.vDelim & &quot;<a name&quot;, &quot;ALL&quot;)>

<!--- Loop though the text file as if it were a list --->
<CFLOOP LIST=&quot;#VARIABLES.vDev#&quot; INDEX=&quot;i&quot; DELIMITERS=&quot;#VARIABLES.vDelim#&quot;>
<!--- Get the book using regular expressions and put it into a variable called vBook --->
<CFSCRIPT>
vBook = ReReplace(i, &quot;(.+)(--)([[:digit:]]?[^[:digit:]]*)([[:digit:]]+)(:)([[:digit:]]+)(.+)&quot;, &quot;\3-\4-\6&quot;);
vBook = Replace(VARIABLES.vBook, &quot; &quot;, &quot;&quot;, &quot;ALL&quot;) & &quot;.vinc&quot;;
</CFSCRIPT>
<CFFILE FILE=&quot;c:\folders\#VARIABLES.vBook#&quot; ACTION=&quot;WRITE&quot; OUTPUT=&quot;#i#&quot; ADDNEWLINE=&quot;No&quot;>
</CFLOOP> - tleish
 
Worked PERFECTLY!

THANKS!

Have a great day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top