Return to Project-GC

Welcome to Project-GC Q&A. Ask questions and get answers from other Project-GC users.

If you get a good answer, click the checkbox on the left to select it as the best answer.

Upvote answers or questions that have helped you.

If you don't get clear answers, edit your question to make it clearer.

coding/regex help please

0 votes
24 views
I am guessing this should be asked in the forum as per the challenge edit section, but I cannot log in there using my GC account and cannot find where to create a user account. So I guess that is question 1. (The standard is to provide a create user option on the user login page).

Question 2:
I am trying to get the first alphanumeric character in a cache name, usually the first character, but not always. The code below looks like it should work, using one of the commented out lines, but none of them do the job. I suspect there is a better regex for the Gsub line, that would do the job too, but I could not work it out (I'm fairly new to this)

Any help would be appreciated, thanks.
Tom

 Print("previous printing\n")
 for i,v in IPairs(myFinds) do
    NoPunct = StringGsub(v['cache_name'],"[%p%s]","")    --removes punctuation
    --initial = StringMatch(NoPunct,"[a-z0-9]")    --gets SECOND letter!!
    --initial = StringSub(NoPunct,1,1)    --produces no Print - not even previous printing!
    --initial = PGC_UTF8_SubStr(NoPunct,1,1) --error msg
      Print (initial,", ",NoPunct,", ", v['cache_name'], "\n")
  end
asked Oct 27, 2014 in Miscellaneous by the Seagnoid (Expert) (34,700 points)
Try logging out (and in again) from PGC to see if that grants you forum-access. It should be single sign-on, but I am aware of that there are unknown issues.

2 Answers

0 votes
 
Best answer
Solved it!

Thanks!
answered Oct 27, 2014 by the Seagnoid (Expert) (34,700 points)
selected Dec 21, 2014 by the Seagnoid (Expert)
0 votes

 initial = StringMatch(v.cache_name,"%a") should work

doing "[%p%s]" is not a lua pattern as you intended it, to replace two different patterns from a string you must run gsub twice, once for each pattern.

/1d

answered Oct 27, 2014 by endator (2,290 points)
...