# Text Parsing Bible Verses

**URL:** https://the.fmsoup.org/t/text-parsing-bible-verses/606
**Category:** Questions
**Tags:** text-processing, format
**Created:** [December 18, 2019, 8:46pm UTC](https://the.fmsoup.org/t/text-parsing-bible-verses/606 "2019-12-18T20:46:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Karlos](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Karlos](https://the.fmsoup.org/u/Karlos)
#### Post date: [December 18, 2019, 8:46pm UTC](https://the.fmsoup.org/t/text-parsing-bible-verses/606/1 "2019-12-18T20:46:25Z")

</div>

For years I've been copying KJV verses from: [https://www.biblegateway.com/](https://www.biblegateway.com/)  
Which when pasted into blogs, articles and debates give me this...

* * *

# Psalm 22:2-4 King James Version (KJV)

2 O my God, I cry in the day time, but thou hearest not; and in the night season, and am not silent.

3 But thou art holy, O thou that inhabitest the praises of Israel.

4 Our fathers trusted in thee: they trusted, and thou didst deliver them.

* * *

## **When I want this...**

Psalm 22:2-4  
2 - O my God, I cry in the day time, but thou hearest not; and in the night season, and am not silent.  
3 - But thou art holy, O thou that inhabitest the praises of Israel.  
4 - Our fathers trusted in thee: they trusted, and thou didst deliver them.

I used Substitute to get rid of "King James Version (KJV)" and change the double ¶¶ to a single ¶, but I'm struggling to add the "dash" between the number and the start of each verse.

I've been experimenting with a loop and various versions of...  
LeftWords ( GetValue ( Tx::Text2 ; PatternCount ( Tx::Text2 ; ¶ ) ) ; 1 ) and I'm inching forwards but would appreciate any advice.

I guess I'm classed as an _intermediate,_ though mostly through trial and error... and error! 😮

The time saved reformatting the text will be hours each month as I am quoting such verses on an almost daily basis and have been for years. Once I have my script I just need to find the quickest way to implement it on my Mac, something I'll consider later.

I purposely didn't include verse 1 above, as it presents a second issue of placing the chapter number in place of the number "1", Why? I don't know, it is simply something the site does and another I'll confront once I have resolved the "Dash" issue....

* * *

# Psalm 22:1-4 King James Version (KJV)

**22** My God, my God, why hast thou forsaken me? why art thou so far from helping me, and from the words of my roaring?

2 O my God, I cry in the day time, but thou hearest not; and in the night season, and am not silent.

3 But thou art holy, O thou that inhabitest the praises of Israel.

4 Our fathers trusted in thee: they trusted, and thou didst deliver them.

* * *

---

<div class="post-metadata">

### Author: ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)
#### Post date: [December 18, 2019, 9:35pm UTC](https://the.fmsoup.org/t/text-parsing-bible-verses/606/2 "2019-12-18T21:35:02Z")

</div>

Make use of the List and Word functions. Carriage returns and line feeds are list delimiters.

```
Set $rawData to [the messy text]
set $n to valueCount( $rawData )
set $i to zero
loop
set $i to $i + 1
exit loop if $i > $n
set $lineText to getValue[$rawData ; $i]
set $lineNumber to LeftWords( $lineText ; 1 )
... and so on,
```

---

<div class="post-metadata">

### Author: ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)
#### Post date: [December 19, 2019, 12:32pm UTC](https://the.fmsoup.org/t/text-parsing-bible-verses/606/3 "2019-12-19T12:32:09Z")

</div>

If the text has the same format from entry to entry, I would first try FMP, but if that's too frustrating, just use a micro-service and the literally hundreds of easy-to-use string formatting methods (aka, functions).

I posted a video here on the forum showing how you can setup a micro-service in about 2 minutes.

HTH

---

<div class="post-metadata">

### Author: ![Otmar](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/otmar/32/703_2.png) [@Otmar](https://the.fmsoup.org/u/Otmar)
#### Post date: [December 19, 2019, 7:20pm UTC](https://the.fmsoup.org/t/text-parsing-bible-verses/606/4 "2019-12-19T19:20:08Z")

</div>

Hi @Karlos welcome to the soup!

Here's a calculation using the While-function introduced with 18, but could also done with a script loop:

```
Let ( [

_text = 
"Psalm 22:2-4¶
2 O my God, I cry in the day time, but thou hearest not; and in the night season, and am not silent.¶
3 But thou art holy, O thou that inhabitest the praises of Israel.¶
4 Our fathers trusted in thee: they trusted, and thou didst deliver them.¶"

] ;

While ( [ 
_thetext = _text
; _nlines = ValueCount ( _thetext ) 
; _result = ""

] ; _nlines > 0 ; [ 

_line = GetValue ( _thetext ; _nlines )
; _leftword = LeftWords ( _line ; 1 )
; _newline = If ( GetAsText ( Filter ( _leftword ; "0123456789" ) ) = _leftword ; _leftword & " - " & RightWords ( _line ; WordCount ( _line ) - 1 ) ; _line )
; _result = List ( _newline ; _result )
; _nlines = _nlines - 1

] ; _result )

)

```

best  
Otmar

---

<div class="post-metadata">

### Author: ![Karlos](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Karlos](https://the.fmsoup.org/u/Karlos)
#### Post date: [December 19, 2019, 8:06pm UTC](https://the.fmsoup.org/t/text-parsing-bible-verses/606/5 "2019-12-19T20:06:26Z")

</div>

Thanks Otmar.  
I've never used 'While' before but will study your reply and see if I can get my head around it! 🙂

Appreciated.

---

<div class="post-metadata">

### Author: ![Karlos](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Karlos](https://the.fmsoup.org/u/Karlos)
#### Post date: [December 19, 2019, 8:07pm UTC](https://the.fmsoup.org/t/text-parsing-bible-verses/606/6 "2019-12-19T20:07:41Z")

</div>

Cheers Malcolm.  
I haven't had time to deal with this yet, but will look at your reply soon.

Appreciated.
