1. Hi all,

    I am looking for a way to find / replace a TAB (\t) char in a string.

    The patterns in string.gsub only let me detect the whitespace characters class. I do not want to replace spaces, just tabs.

    A general Google search didn't give me anything useful. Supposedly string.gsub(strText, "\t', "|") or string.gsub(strText, "<insert a tab here>', "|") should work, but they don't.

    I haven't yet found a pattern that says "all whitespace characters except space" either.

    Do you know of a way?

    Tia,

    Rob.

    Hi all,

    I am looking for a way to find / replace a TAB (\t) char in a string.

    The patterns in string.gsub only let me detect the whitespace characters class. I do not want to replace spaces, just tabs.

    A general Google search didn't give me anything useful. Supposedly string.gsub(strText, "\t', "|") or string.gsub(strText, "<insert a tab here>', "|") should work, but they don't.

    Yes they do.

     foo = "monkey\tapple\tbanana"
     print(#foo) -- 19
     bar = foo:gsub("\t", "TAB")
     print(#foo) -- 23
     print(bar)  -- monkeyTABappleTABbanana
    

    That's how you do it.

    I haven't yet found a pattern that says "all whitespace characters except space" either.

    There isn't one, and there doesn't really need to be. That would be WAY too 'special purpose' when you can already do this on your own.

    Hope that helps.

    Thanks for that one.

    It didn't help me much, unfortunately.

    If I use the snippet as you gave it, it works, even if I replace the \t with "real" tabs. If I read the same string from a text box in the WoW UI (as is the case for the addon), it doesn't work anymore.

    Is there anything in that area that I could look at?

    Tabs are not supported by WoW.. so I am afraid I am confused. Also, \t IS a real tab.. so I have no idea what you're talking about.

    \t embedded in a Lua string is the tab character.. there is nothing else.

    What precisely are you trying to do?

    I'm trying to parse a copied text (eqdkp standings) into a table

    example table: http://www.low-landers.nl/dkp/listmembers.php

    addon in question: whisperloot3.googlecode.com (core.lua, line 1253)

    I copy the table from the website into the text box in the addon. I then parse the data. The tabs in the copied string are column separators on the web page. I am trying to use them as such to separate out column values, as not all values are present all the time.

    Then I suspect the data isn't appearing as you think it is. Store it in a string and parse it character by character to see what is actually there. The only real thing you have to worry about is the presence of the vertical bar (pipe) character. Anytime that appears in a chat frame edit box it gets doubled.

    Unfortunately I don't have time to look into all of the details of what you're trying to do.. but as you can see.. performing gsubs and other pattern matching on tabs most certainly works, which means if its not working its either the algorithm.. or the data is not what you think it is. You can test both of these, I can't =)

    I hadn't yet copied the data back out of the text box again to see what's actually in there. Will try that next.

    Will try the char-by-char. Thanks for that (and, yes, perhaps it's the algorithm :)

    EDIT

    Major bummer. Wow actually expands the tabs when text is copied from the web site into the text box. Back to the drawing board it is...

    Like I said, the widgets don't support tabs. Perhaps you could get the php page to actually output something reasonable, like CSV?

    Trying Getdkp next, it has a server-side script that outputs a Lua string that can be directly parsed with loadstring()

    Thanks for the pointers so far :)