objective c - extracting a string from a text field I get "Thread 1: signal SIGABRIT" if the character before the extract is a number -
i using tesseract scan driving license, , want pre-populate fields using extracted information.
the format of license goes:
- wills
- matthew david ... etc
my code (which add @ bottom) works if looking "david" , start search "matthew" ending "\n" however, if start "1. " trying find "wills" after scan app crashes.
for record, "4a." works well, it's more can't "end" number, or "only" have number, either way, number consistent character have use key search, can change in code, work above example.
it works this:
nsregularexpression *regexp = [nsregularexpression regularexpressionwithpattern:@"1(.*?)\n" options:nsregularexpressioncaseinsensitive error:nil]; [regexp enumeratematchesinstring:tesseracttext.text options:0 range:nsmakerange(0, tesseracttext.text.length) usingblock:^(nstextcheckingresult *match, nsmatchingflags flags, bool *stop) { nsrange group1 = [match rangeatindex:1]; tesseracttext.text = [tesseracttext.text substringwithrange:group1]; // changes textfield value of specific text } ];
in example, simple change current textfield text searching for, testing mechanism before implementing full code, rest assured, didn't create bugs previous searches (starting , ending letters, starting letters , ending \n, or starting 4a. , ending \n, refused work "1. " "1" "2 " or "2."
nsregularexpression *regexp = [nsregularexpression regularexpressionwithpattern:@"matthew (.*?)\n"
works when searching david
any suggestions on how can work, numbers @ start of each line go by?
thanks!
the sigabrt because assuming there rangeatindex:1
. must not assume that. objective-c indexes start @ 0. first , guaranteed range rangeatindex:0
. if want know whether there further ranges, need ask numberofranges
.
Comments
Post a Comment