-2

I have several documents on a folder. Some of them, has this kind of text:

text="???????????????????????????????????? ??????????????????????? ?????????????????????????????????? ????????????? ???????????????????? ?????? ? ? ???? ????????????? ??????????? ????????????????????? ?????? ? ? ???? ????????? ?????????????????? ??????????????????????? ??????????? ????? ??????? ?????????????? ??????????????????????? ?????? ? ? "

I would like to recognize these documents and put this variable text like: text="".

My problem is, how could I recognize this pattern? as you see, there are several "?" repeated with no identical number of repeats. The pattern should be "if there is no text and only "?" characters, delete content.

Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
AlexMJ
  • 89
  • 1
  • 9
  • This looks like an artefact of not handling Unicode correctly. Is this an [xy problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)? – Phylogenesis Jan 26 '15 at 11:11
  • First Idea, something like this: string = string.find (text, "%w") print(string) – AlexMJ Jan 26 '15 at 11:12
  • Thanks @Phylogenesis. I'm trying to solve it, but I'm worried about delete something I wouldn't. – AlexMJ Jan 26 '15 at 11:14

1 Answers1

2

Use the pattern "[?%s]*", which means zero or more of ? or whitespace characters.

if text:gsub("[?%s]*", "") == "" then
  -- do something
end
Yu Hao
  • 119,891
  • 44
  • 235
  • 294