string.find how to use Init

Hi,

Can I use 88000 in the Init Parameter?

In fact, I want to find a string after 88000 characters.

that’s possible? What is the limit for this parameter?

Ty so much.

This is a general Lua question, not really specific to Vera. Lua strings appear to be up to as long as you can specify in an int, so about 2 billion. It’s probable that the arguments for string.find() also take ints.

Having so long a string in a Lua variable is going to use a lot of RAM. Depending on what you want to achieve, see if you can discard any of those first eighty thousand characters before you run the string.find().

I want to find a string “

  • X
  • ” into a html page at line 585 - 87,582 characters…

    this string is used 2 times in the html page. At line 585 and 635. I want to difference them

    So you are going to fetch the entire web page into a string, and then search through the string. I think that should work.

    If it doesn’t, come back and we can talk about ways to stream the HTML piece by piece.

    Hi,

    my request string.find doesn’t work.

    The string to find is :

  • X
  • I think string.find(url, “

  • X
  • ”, 88217) is not good… :frowning:

    String.find() does not go out onto the web and fetch the HTML page for you. You have to do that yourself, possibly with luup.inet.wget() or another function.

    How about you post the code that you have already tried, along with a description of what you think that code is doing, and we can see where your expectation diverges from reality?

    Also string.find does a regex search if you don’t set the fourth argument to true. I don’t see any magic character in your pattern string, so this shouldn’t be a problem, however, doing a plain text search is noticeable faster than doing a regex search.