Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:00:52+00:00 2026-06-09T23:00:52+00:00

I have a string stored in sqlite database and I’ve assigned it to a

  • 0

I have a string stored in sqlite database and I’ve assigned it to a var, e.g. string

string = “First line and string. This should be another string in a new line”

I want to split this string into two separated strings, the dot (.) must be replace with (\n) new line char

At the moment I’m stuck and any help would be great!!

for row in db:nrows("SELECT * FROM contents WHERE section='accounts'") do
    tabledata[int] = string.gsub(row.contentName, "%.", "\n")
    int = int+1
end

I tried the other questions posted here in stachoverflow but with zero luck

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:00:53+00:00Added an answer on June 9, 2026 at 11:00 pm

    Are you looking to actually split the string into two different string objects? If so maybe this can help. It’s a function I wrote to add some additional functionality to the standard string library. You can use it as-is or rename it to what ever you like.

    --[[
    
        string.split (s, p)
        ====================================================================
        Splits the string [s] into substrings wherever pattern [p] occurs.
    
        Returns: a table of substrings or, if no match is made [nil].
    
    --]]
    string.split = function(s, p)
        local temp = {}
        local index = 0
        local last_index = string.len(s)
    
        while true do
            local i, e = string.find(s, p, index)
    
            if i and e then
                local next_index = e + 1
                local word_bound = i - 1
                table.insert(temp, string.sub(s, index, word_bound))
                index = next_index
            else            
                if index > 0 and index <= last_index then
                    table.insert(temp, string.sub(s, index, last_index))
                elseif index == 0 then
                    temp = nil
                end
                break
            end
        end
    
        return temp
    end
    

    Using it is very simple, it returns a tables of strings.

    Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
    > s = "First line and string. This should be another string in a new line"
    > t = string.split(s, "%.")
    > print(table.concat(t, "\n"))
    First line and string
     This should be another string in a new line
    > print(table.maxn(t))
    2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have date stored as string in an sqlite database like 28/11/2010. I want
I have this string stored in a variable: IN=bla@some.com;john@home.com Now I would like to
I have stored the XML path to items in a string like this: response->items->item
Guys i have stored a null value in the column of sqlite database the
I have HTML page, CSS, JAVA and images all stored in my SQLite database.
I'm new to the Android SQLite whole thing. This is what I have: I
i have string stored in python variables, and i am outputting a html that
In my applications web.config file I have a connection string stored. I encrypted it
I have a variable, emailBody, which is set to a string stored in a
I have a string that contains HTML image elements that is stored in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.