Question:
Sometimes while using TextSearch class the function textSearch.Begin(doc, pattern, mode)
throws the following exception.
Message: The instance hasn't been initialized yet.
Conditional expression: false
Version : 10.6.0-9bc7df1d1b
Platform : OSX
Architecture : Arm
Filename : TextSearch.cpp
Function : Run
Linenumber : 1053
Answer:
This exception means there is something wrong with the pattern
parameter passed to TextSearch.Begin()
Possible causes are:
- Empty string
- Invalid unicode
- regex syntax error
Though the most common cause is empty search pattern. In such a case, best to just simply not call TextSearch.Begin() since there is nothing to return anyway.