Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3773

Regex Search and Simplified Chinese

$
0
0

Can you do a Regex search a Dictionary type if the data is Simplified Chinese?


err = new RegExException

redim whereToPut(-1)                      // reset results array
Found = false                                  
rg = New RegEx                                        // setup for search via RegEx

// make sure there is something in whatToFind
if whatToFind = "" then
  Raise err
end if
// check for proper search syntax
rg.SearchPattern = "[^a-zA-Z0-9{}.,*]" // limit search characters
if rg.Search(whatToFind) <> nil then
  raise err
end if

// Set search for input length of word

rg.SearchPattern = "^"+whatToFind+"\b" 

// setup search index
if midB(whatToFind,1,1) = "." then
  j = 0
  k = UBound(wordList)
else
  temp = asc(Uppercase(mid(whatToFind,1,1))) - 65  // index a=0 
  if temp > 0 then
    j = wordIndex(temp)                       //start of a letter
    k = wordIndex(temp + 1) - 1          // end of a letter
  else
    exit
  end if
end if

// Search the wordlist using RegEx
For i = j to k         
  if rg.search(wordList(i)) <> nil then
    Found = true
    whereToPut.append wordList(i)
  end if
next

return Found

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 3773

Trending Articles