Package: ctextlib
CTextAdvanced text processing library in C++ and PythonAboutA Modern C++ library with many useful text processing routines. CText can solve some complicated text processing tasks that otherwise are taking too much time in C++ and Python, some of these like managing lines and words are available on higher level languages like C#, Java and Python but not in C++. But C++ gives more low-level control, except supporting the missing text functions CText implements optimized text routines. Library is very flexible and scalale, it is easy to add quickly custom text processing routnes, can be used to make  pre-processing problems for different NLP and ML tasks or just to practice Modern C++.Main FeaturesModern C++ Template library: You only need to include one header, very simple to use.Unicode Support: - you can have both UNICODE and ANSI in one project.Hundreds of optimized text processing methods: - Many standard and non-standard text processing operations are covered. I have a long TODO list with much more to add.Clean and easy to understand code: - You can use CText to quickly start more complicated text processing applications and abstracting from the too many lower level details and optimizations.Portable:  I am using CText with VS2017/VS2019 and GCC 7.4 but it easily can be ported to other platforms.Stand alone:  CText do not depends on any other libraries, the only requirements are C++11 and STLScalable:  All text routines are easily to be further extended for all commonly supported char types and platforms.Python:  Support of all Python versionsPlease feel free to contact me for questions or suggestions.PythonTo install CText:pip install ctextlibTo test if CText is installed:importctextliba=ctextlib.Text("Hello World")print(a)Or:fromctextlibimportTextastexta=text("Hello World")print(a)Python methods reference:addToFileNamea=text("C:\\Temp\\Temp2\\File.bmp")a.addToFileName("_mask")print(a)C:\Temp\Temp2\File_mask.bmpappenda=text("Hello ")a.append("World")Hello Worlda=text("123")a.append('4',4)1234444a=text("")a.append(['Hello',' ','World'])Hello WorldappendRangea=text()a.appendRange('a','z').appendRange('0','9')abcdefghijklmnopqrstuvwxyz0123456789betweena=text('The quick brown fox jumps over the lazy dog')a.between('q','d')print(a)uick brown fox jumps over the lazya=text('The quick brown fox jumps over the lazy dog')a.between('quick','lazy')print(a)brown fox jumps over thecontaina=text('The quick brown fox jumps over the lazy dog')ifa.contain('quick'):print("contain 'quick'")contain 'quick'Case-incensitivea=text('The quick brown fox jumps over the lazy dog')ifa.contain('Quick',False):print("contain 'quick'")contain 'quick'a=text('The quick brown fox jumps over the lazy dog')ifa.contain(['slow','fast','quick']):print("contain 'quick'")contain 'quick'containAnya=text('Hello World')a.containAny('abcd')TruecontainOnlya=text('4365767')a.containOnly('0123456789')Truecounta=text('The quick brown fox jumps over the lazy dog')a.count('the',False)2countWordFrequenciesfromctextlibimportTextastexta=text("The quick brown fox jumps over the lazy dog")a.countWordFrequencies(False)[(2, 'the'), (1, 'brown'), (1, 'dog'), (1, 'fox'), (1, 'jumps'), (1, 'lazy'), (1, 'over'), (1, 'quick')]cutAfterFirsts=text('The quick brown fox jumps over the lazy dog')a.cutAfterFirst('o')The quick brcutAfterLasts=text('The quick brown fox jumps over the lazy dog')a.cutAfterLast('o')The quick brown fox jumps over the lazy dcutBeforeFirsts=text('The quick brown fox jumps over the lazy dog')a.cutBeforeFirst('o')own fox jumps over the lazy dogcutEndss=text('The quick brown fox jumps over the lazy dog')a.cutEnds(4)quick brown fox jumps over the lazycutLefts=text("Hello World")s.cutLeft(6)WorldcutRights=text("Hello World")s.cutRight(6)Helloenclosea=text("Hello World")a.enclose('<','>')a.enclose('"')<Hello World>
"Hello World"endsWitha=text("Hello World")ifa.endsWith('World'):print("ends with 'World'")ends with 'World'With case-insensitive search:a=text("Hello World")ifa.endsWith('world',False):print("ends with 'world'")ends with 'world'endsWithAnyif(a.endsWithAny(['cat','dog'])):print('end to animal...')end to animal...erasea=text('The quick brown fox jumps over the lazy dog')a.erase(8,10)print(a)The quicx jumps over the lazy dogequala=text()a.equal('A',10)AAAAAAAAAAfinda=text('The quick brown fox jumps over the lazy dog')a.find('brown')'brown fox jumps over the lazy dog'With case-incensitive search:a=text('The quick brown fox jumps over the lazy dog')a.find('Brown',False)'brown fox jumps over the lazy dog'fromArraya=text()a.fromArray([1,2,3,4])print(a)1 2 3 4a=text()a.fromArray([1,2,3,4],'|')print(a)1|2|3|4a=text()a.fromArray([1,2,3,4],'')print(a)1234Array of floatsa=text()a.fromArray([1.1,2.2,3.3,4.4])print(a)1.1 2.2 3.3 4.4Array of stringsa=text()a.fromArray(['hello','world'])print(a)hello worldimportnumpyasnpa=text()a.fromArray(np.array(["hello","world"]))print(a)hello worldfromArrayAsHexa=text()a.fromArrayAsHex([10,20,30,40])print(a)0A 14 1E 28Use without separatora.fromArrayAsHex([10,20,30,40],2,'')print(a)0A141E28a=text()a.fromArrayAsHex([1000,2000,3000,4000])print(a)3E8 7D0 BB8 FA0a=text()a.fromArrayAsHex([1000,2000,3000,4000],4,',')print(a)03E8,07D0,0BB8,0FA0fromBinarya=text()a.fromBinary(12345)print(a)00000000000000000011000000111001fromDoublea=text()a.fromDouble(3.333338478)print(a)a.fromDouble(3.33989,4)print(a)a.fromDouble(3.333338478,10)3.333338
3.3399
3.3333384780fromHexa=text()a.fromHex(1234567)a.fromHex('a')a.fromHex("48 65 6C 6C 6F 20 57 6F 72 6C 64")0012D687
61
Hello WorldfromIntegera=text()a.fromInteger(358764)print(a)358764fromMatrixfromctextlibimportTextastextimportnumpyasnpx=np.array([[10,20,30],[40,50,60]])a=text()a.fromMatrix(x)print(a)10 20 30
40 50 60fromctextlibimportTextastextimportnumpyasnpx=np.array([[10,20,30],[40,50,60]])a=text()a.fromMatrix(x,',')10,20,30
40,50,60fromMatrixAsHexfromctextlibimportTextastextimportnumpyasnpx=np.array([[10,20,30],[40,50,60]])a=text()a.fromMatrixAsHex(x)print(a)0A 14 1E
28 32 3CfromctextlibimportTextastextimportnumpyasnpx=np.array([[1000,2000,3000],[4000,5000,6000]])a=text()a.fromMatrixAsHex(x,4)print(a)03E8 07D0 0BB8
0FA0 1388 1770getDira=text("D:\\Folder\\SubFolder\\TEXT\\file.dat")a.getDir()D:\Folder\SubFolder\TEXT\getExtensiona=text("D:\\Folder\\SubFolder\\TEXT\\file.dat")a.getExtension()'.dat'getFileNamea=text("D:\\Folder\\SubFolder\\TEXT\\file.dat")a.getFileName()'file.dat'hashs.hash()9257130453210036571indexOfa=text("The quick brown fox jumps over the lazy dog.")a.indexOf("brown")10indexOfAnya=text("The quick brown fox jumps over the lazy dog.")a.indexOfAny(["fox","dog"])16indexOfAnya=text("The quick brown fox jumps over the lazy dog.")a.indexOfAny("abc")7inserta=text("abc")a.insert(1,'d',2)addbca=text("The quick jumps over the lazy dog.")a.insert(10,"fox ")The quick fox jumps over the lazy dog.insertAtBegininsertAtEnda=text("Hello")a.insertAtBegin("<begin>")a.insertAtEnd("</begin>")<begin>abc</begin>isAlphaa=text("Abcd")a.isAlpha()TrueisBinarya=text("01111011100001")a.isBinary()TrueisEmptya=text()a.isEmpty()TrueisHexNumbera=text("12AB56FE")a.isHexNumber()TrueisNumbera=text("123456")a.isNumber()TrueisLowera=text("hello world")a.isLower()TrueisUppera=text("HELLO WORLD")a.isUpper()TrueisPalindromea=text("racecar")a.isPalindrome()Truekeeps=text("Hello World").keep(3,5)lo WokeepLefta=text("The quick jumps over the lazy dog.")a.keepLeft(10)The quickkeepRighta=text("The quick jumps over the lazy dog.")a.keepRight(10)lazy dog.lastIndexOfs=text("Hello World")s.lastIndexOf('l')9linesa=text("L1\nL2\n\nL3\nL4\n\n\nL5")a.lines()['L1', 'L2', 'L3', 'L4', 'L5']linesCounta=text("L1\nL2\n\nL3\nL4\n\n\nL5")a.linesCount()7linesRemoveEmptya=text("L1\nL2\n\nL3\nL4\n\n\nL5")a.linesRemoveEmpty()print(a)L1
L2
L3
L4
L5Several per line methodslinesAppendlinesInsertAtBeginlinesSortlinesPaddRightlinesTrimExample of opening a text file, sort all lines, and save it with another namefromctextlibimportTextastexts=text()s.readFile('Unordered.txt')s.linesSort()s.writeFile('Sorted_python.txt')limits=text("Hello World")s.limit(6)Hellolowers=text("Hello World")s.lower()hello worldmakeUniquea=text()a.appendRange('a','z').appendRange('a','z')abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza.makeUnique()print(a)abcdefghijklmnopqrstuvwxyzmida=text("Hello World").mid(3)lo WonextLine# Example of iterating all linesfromctextlibimportTextastexta=text("Line1\nLine2\nLine3")line=text()pos=0while(pos>=0):pos=a.nextLine(pos,line)print(line)Line1
Line2
Line3nextWord# Example of iterating all wordsfromctextlibimportTextastexta=text('The quick brown fox jumps over the lazy dog')word=text()pos=0while(pos>=0):pos=a.nextWord(pos,word)print(word)The
quick
brown
fox
jumps
over
the
lazy
dogpaddLefts=text("Abra")s.paddLeft('.',16)............AbrapaddRights=text("Abra")s.paddRight('.',16)Abra............pathCombinea=text("C:\\Temp")a.pathCombine("..\\Folder")C:\Folderquotea=text("Hello")a.quote()"Hello"randoma=text()a.random()"P1kAlMiG2Kb7FzP5"a.sort()"1257AFGKMPPbiklz"a.shuffle()"k2lF7KAPG5M1Pzbi"a.random(32)P1kAlMiG2Kb7FzP5tM1QBI6DSS92c31ArandomAlphas=text()s.randomAlpha()IkEffmzNiMKKASVWrandomNumbers=text()s.randomNumber()3892795431s.randomNumber(32)33341138742779319865028602486509readFile# demontrates how to read a whole text filefromctextlibimportTextastexta=text()a.readFile('test.txt')print(a)Hello WorldregexMatchs=text("+336587890078")if(s.regexMatch("(\\+|-)?[[:digit:]]+")):print("it is a number")it is a numberregexLinesanimals.txt
------------
Cat
Dog
Giraffe
Lion
Llama
Monkey
Mouse
Parrot
Poodle
Scorpion
Snake
Weasel# collect all lines starting with given charactersfromctextlibimportTextastexta=text()a.readFile("animals.txt")a.regexLines("^[A-G][a-z]+")['Cat', 'Dog', 'Giraffe']regexReplacefromctextlibimportTextastexta=text("there is sub-sequence in the sub-way string")a.regexReplace("\\b(sub)([^ ]*)","sub-$2")there is sub--sequence in the sub--way stringregexSearch# collect all words using regexfromctextlibimportTextastexta=text("The quick brown fox jumps over the lazy dog")a.regexSearch("\\w+")'The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']regexWords# collect all words starting with given charactersfromctextlibimportTextastexta=text("The quick brown fox jumps over the lazy dog")a.regexWords("^[a-n][a-z]+")['brown', 'fox', 'jumps', 'lazy', 'dog']removea=text('we few, we happy few, we band of brothers.')a.remove('we')a.reduceChain()a.trim()few happy few band of brothersremoveAnyfromctextlibimportTextastexta=text('The quick brown fox jumps over the lazy dog')a.removeAny(['brown','quick','lazy'])a.reduceChain()The fox jumps over the dogremoveExtensiona=text("D:\\Folder\\SubFolder\\TEXT\\File.dat")a.removeExtension()D:\Folder\SubFolder\TEXT\FileremoveFileNamea=text("D:\\Folder\\SubFolder\\TEXT\\File.dat")a.removeFileName()D:\Folder\SubFolder\TEXT\removeWhileBeginsa=text("Some text ending with something")a.removeWhileBegins("Some text ")print(a)ending with somethingremoveWhileEndsa=text("Some text ending with something")a.removeWhileEnds(" something")print(a)Some text ending withreplacea=text("The quick brown fox jumps over the lazy dog")a.replace("fox","cat")print(a)The quick brown cat jumps over the lazy doga=text("The quick brown fox jumps over the lazy dog")a.replace(["fox","cat","dog","quick"],"-")The ----- brown --- jumps over the lazy ---replaceAnya=text("The quick brown fox jumps over the lazy dog")a.replaceAny(["fox","cat","dog"],"***")print(a)The quick brown *** jumps over the lazy ***a=text("The quick brown fox jumps over the lazy dog")a.replaceAny(["fox","dog"],["dog","fox"])The quick brown dog jumps over the lazy foxreversea=text("Hello")a.reverse()olleHrighta=text("Hello World")a.right(5)Worldrotatea=text("Hello World")a.rotateLeft(2)a.rotateRight(4)Outputllo WorldHe
ldHello Worsplit# by default split uses the standard separators (" \t\r\n")a=text("The quick brown fox jumps over the lazy dog")a.split()['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']# split can be used with any list of separator charactersa=text("The quick, brown....fox,,, ,jumps over,the  lazy.dog")a.split(",. ")['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']toBinarybOk=Falsea=text("100001")a.toBinary(bOk)33toHexa=text("Hello World")a.toHex()print(a)48 65 6C 6C 6F 20 57 6F 72 6C 64Using separator character.a=text("Hello World")a.toHex(',')print(a)48,65,6C,6C,6F,20,57,6F,72,6C,64toHexbOk=Falsea=text("1E1E")a.toHex(bOk)7710trima=text("\t\nlazy dog\t\n")a.trim()lazydoga=text("000000000000101")a.trimLeft("0")101a=("101000000000000")a.trimRight('0')101a=text("0000000101000000000")a.trim("0")101uppers=text("Hello World")s.upper()HELLO WORLDwordsa=text("The quick brown fox jumps over the lazy dog")a.words()['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']a=text("The|quick|brown|fox|jumps|over|the|lazy|dog")a.words('|')['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']wordsCapitalizea=text("The quick brown fox jumps over the lazy dog")a.wordsCapitalize()The Quick Brown Fox Jumps Over The Lazy DogwordsCounta=text('The quick brown fox jumps over the lazy dog')a.wordsCount()9wordsEnclosea=text("The quick brown fox jumps over the lazy dog")a.wordsEnclose('[',']')[The] [quick] [brown] [fox] [jumps] [over] [the] [lazy] [dog]wordsReversea=text("The quick brown fox jumps over the lazy dog")a.wordsReverse()ehT kciuq nworb xof spmuj revo eht yzal godwordsSorta=text('The quick brown fox jumps over the lazy dog')a.wordsSort()OutputThe brown dog fox jumps lazy over quick thewriteFile# demontrates how to write to a text filefromctextlibimportTextastexta=text("Hello World")a.writeFile('test.txt')print(a)UNICODE for PythonPython is using UTF8 as strings representation. When using Python texts containing non-English Unicode characters it is recommended to use the Unicode version of CText as demonstrated below:# demonstrate text processing of Swedish unicode textfromctextlibimportTextUastexts=text('Den snabbbruna räven hoppar över den lata hunden')>>>s.cutBeforeFirst('ö')över den lata hunden# demonstrate text processing of Russian unicode textfromctextlibimportTextUastexts=text('Быстрая коричневая лиса прыгает на ленивую собаку')s.cutAfterLast('ы')Быстрая коричневая лиса пр# demonstrate text processing of Czech unicode textfromctextlibimportTextUastexts=text('Rychlá hnědá liška skočí přes líného psa')s.cutAfterFirst('á',True)Rychlá# demonstrate text processing of Greek unicode textfromctextlibimportTextUastexts=text('Η γρήγορη καφέ αλεπού πηδάει πάνω από το τεμπέλικο σκυλί')s.cutAfterFirst('έ',True)Η γρήγορη καφέ# demonstrate text processing of Armenian unicode textfromctextlibimportTextUastexts=text('Արագ շագանակագույն աղվեսը ցատկում է ծույլ շան վրա')s.cutBeforeFirst('է')է ծույլ շան վրա# demonstrate text processing of Georgian unicode textfromctextlibimportTextUastexts=text('სწრაფი ყავისფერი მელა გადაბმულია ზარმაცი ძაღლი')s.cutBeforeFirst('მ')მელა გადაბმულია ზარმაცი ძაღლიFor the full info type help(text).Build CText Unit Test and Demo projectsTo build the UnitTest project and the demos with CMake and Visual Studio:open terminal in the folder \Apps and typecmake .Alternatively, you can load in VS2017 or later \Apps\CMakeLists.txt from File->Open->CMake.., after generates cache is completed, choose CMake->Build AllTo compile with GCC in Debug or Release:cmake -D CMAKE_BUILD_TYPE=Release .cmake -D CMAKE_BUILD_TYPE=Debug .This will build a console application that runs the Unit Tests.Also there is a Visual Studio solution (CText.sln) with all projects. Run UnitTests project first to see if all tests pass.## C++ ExamplesFor all examples how to use CText please see the Unit Test project.Sort all lines in a text file// this example reads a text file and sorts all lines in alphabeta order.#include<iostream>#include"../CTEXT/CText.h"#include"tchar_utils.h"intmain(){constchar*input_name="/Unsorted.txt";constchar*output_name="/Sorted.txt";CTextpathIn=getcwd(0,0);CTextpathOut=pathIn;pathIn+=input_name;pathOut+=output_name;CTextstr;if(!str.readFile(pathIn.str())){std::cerr<<"Error, can not open file: "<<pathIn<<std::endl;return0;}str.linesSort();str.writeFile(pathOut.str(),CText::ENCODING_ASCII);return0;}Replace wordsCTexts=_T("The quick brown fox jumps over the lazy dog");s.replace(_T("brown"),_T("red"));cout<<s<<endl;Output:The quick red fox jumps over the lazy dogCTexts=_T("The quick brown fox jumps over the lazy dog");constCText::Char*words[]={_T("quick"),_T("fox"),_T("dog")};s.replaceAny(words,3,_T('-'));cout<<s<<endl;Output:The ----- brown --- jumps over the lazy ---CTexts=_T("The quick brown fox jumps over the lazy dog");s.replaceAny({_T("fox"),_T("dog")},{_T("dog"),_T("fox")});cout<<s<<endl;CTexts=_T("The quick brown Fox jumps over the lazy Dog");s.replaceAny({_T("fox"),_T("dog")},{_T("dog"),_T("fox")},false);cout<<s<<endl;Output:The quick brown dog jumps over the lazy foxCTexts=_T("The quick brown fox jumps over the lazy dog");constCText::Char*words[]={_T("quick"),_T("fox"),_T("dog")};s.replaceAny(words,3,_T("****"));cout<<s<<endl;Output:The **** brown **** jumps over the lazy ****Remove words, blocks and charactersCTexts=_T("This is a monkey job!");s.remove(_T("monkey"));s.reduceChain(' ');cout<<s<<endl;Output:This is a job!CTexts=_T("Text containing <several> [blocks] separated by {brackets}");s.removeBlocks(_T("<[{"),_T(">]}"));s.reduceChain(' ');s.trim()cout<<s<<endl;Output:Text containing separated bys=_T("one and two or three and five");s.removeAny({_T("or"),_T("and")});s.reduceChain(' ');cout<<s<<endl;Output:one two three fiveFile pathsCTextfilepath=_T("D:\\Folder\\SubFolder\\TEXT\\File.dat");cout<<filepath.getExtension()<<endl;cout<<filepath.getFileName()<<endl;cout<<filepath.getDir()<<endl;filepath.replaceExtension(_T(".bin"));cout<<filepath<<endl;filepath.removeExtension();cout<<filepath<<endl;filepath.replaceExtension(_T(".dat"));cout<<filepath<<endl;filepath.replaceFileName(_T("File2"));cout<<filepath<<endl;filepath.addToFileName(_T("_mask"));cout<<filepath<<endl;filepath.replaceLastFolder(_T("Temp"));cout<<filepath<<endl;filepath.removeAfterSlash();cout<<filepath<<endl;Output.dat
File.dat
D:\Folder\SubFolder\TEXT\
D:\Folder\SubFolder\TEXT\File.bin
D:\Folder\SubFolder\TEXT\File
D:\Folder\SubFolder\TEXT\File.dat
D:\Folder\SubFolder\TEXT\File2.dat
D:\Folder\SubFolder\TEXT\File2_mask.dat
D:\Folder\SubFolder\Temp\File2_mask.dat
D:\Folder\SubFolder\TempCTextpath1(_T("C:\\Temp"));CTextpath2(_T("..\\Folder"));path1.pathCombine(path2.str());cout<<path1<<endl;OutputC:\\FolderSplit and collection routinesCTexts=_T("The quick  brown fox jumps  over the lazy dog");vector<CText>words;if(s.split(words)<9)cout<<"Error!"<<endl;for(auto&s:words)cout<<s<<endl;CTexts=_T("The,quick,brown,fox,jumps,over,the,lazy,dog");vector<std::string>words;if(s.split(words,false,_T(","))!=9)cout<<"Error!"<<endl;for(auto&s:words)cout<<s<<endl;Output:The
quick
brown
fox
jumps
over
the
lazy
dogCTexts="Line 1\r\nLine 2\n\nLine 3\n";vector<std::string>lines;s.collectLines(lines);for(auto&s:lines)cout<<s<<endl;Output:Line 1
Line 2
Line 3Read sentences from text file#include<iostream>#include"../CTEXT/CText.h"#include"tchar_utils.h"intmain(){constchar*input_name="/Columbus.txt";constchar*output_name="/Columbus_Sentences.txt";CTextpathIn=getcwd(0,0);CTextpathOut=pathIn;pathIn+=input_name;pathOut+=output_name;CTextstr;if(!str.readFile(pathIn.str())){std::cerr<<"Error, can not open file: "<<pathIn<<std::endl;return0;}std::vector<CText>sentences;str.collectSentences(sentences);str.fromArray(sentences,_T("\n\n"));str.writeFile(pathOut.str(),CText::ENCODING_UTF8);return0;}Count characters and wordsCTexts=_T("12345678909678543213");map<CText::Char,int>freq;s.countChars(freq);CTexts=_T("Nory was a Catholic because her mother was a Catholic, and Nory’s mother was a Catholic because her father was a Catholic, and her father was a Catholic because his mother was a Catholic, or had been.");std::multimap<int,CText,std::greater<int>>freq;s.countWordFrequencies(freq);s.fromMap(freq);cout<<s;Output:Catholic 6
a 6
was 6
because 3
her 3
mother 3
and 2
father 2
Nory 1
Nory's 1
been 1
had 1
his 1
or 1Conversion routinesCTexts=_T("1 2 3 4 5 6 7 8 9");vector<int>v;s.toArray<int>(v);Output:{1,2,3,4,5,6,7,8,9}CTexts=_T("1,2,3,4,5,6,7,8,9");vector<int>v;s.toArray<int>(v,_T(','));Output:{1,2,3,4,5,6,7,8,9}CTexts=_T("1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9");vector<double>v;s.toArray<double>(v,_T(','));Output:{1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9}From hexadecimal numbers array:CTexts=_T("0A 1E 2A 1B");vector<int>v;s.toArray<int>(v,_T(' '),true);Output:{10, 30, 42, 27}CTexts=_T("1a:2b:3c:4d:5e:6f");vector<int>v;s.toArray<int>(v,_T(':'),true);Output:{26, 43, 60, 77, 94, 111}Without separator:CTexts=_T("0A1E2A1B");s.toArray<int>(v,0,true);Output:{10, 30, 42, 27}ConverthextocharsstringCTexts=_T("48 65 6C 6C 6F 20 57 6F 72 6C 64");std::vector<int>bytes;s.toChars<int>(bytes,true);s.fromChars<int>(bytes);cout<<s<<endl;Output:Hello WorldParse numerical matrix:std::vector<std::vector<int>>m;CTexts=_T("1 2 3\n4 5 6\n7 8 9");s.toMatrix<int>(m,_T(' '));Output:{
    {1, 2, 3},
    {4, 5, 6},
    {7, 8, 9},
};Highlight wordsFollowing will make bold all words starting with "Col", "Spa","Isa", ending to "an"), "as" or containing "pe" or "sea":vector<CText>start={_T("Col"),_T("Spa"),_T("Isa")};vector<CText>end={_T("an"),_T("as")};vector<CText>contain={_T("pe"),_T("sea")};str.wordsEnclose(_T("<b>"),_T("</b>"),&start,&end,&contain);Portugal had been the mainEuropeanpower interested in pursuing trade routesoverseas. Their next-door neighbors, Castile (predecessor ofSpain) had been somewhat slower to begin exploring the Atlanticbecauseof the bigger land area it had to re-conquer (the Reconquista) from the Moors. Itwasnot until the late 15th century, following the dynastic union of the Crowns of Castile and Aragon and the completion of the Reconquista, that the unified crowns of what would becomeSpain(although countries still legally existing) emerged and became fully committed to looking for new trade routes and coloniesoverseas. In 1492 the joint rulers conquered the Moorish kingdom of Granada, which had been providing Castile withAfricangoods through tribute.Columbushad previously failed to convince King John II of Portugal to fund his exploration of a western route, but the new king and queen of the re-conqueredSpaindecided to fundColumbus'sexpedition in hopes of bypassing Portugal's lock on Africa and theIndianOcean, reaching Asia by traveling westColumbuswasgrantedanaudience with them; on May 1, 1489, hepresentedhis plans to QueenIsabella, who referred them to a committee. They pronounced the idea impractical, andadvisedthe monarchs not to support theproposedventureTODO ListMore methods for words,lines,sentences and complex expressions:  There are lots more methods that can be added to support diferent NLP and lexical tasks.Further improve containers abstraction: CText needs more convertion routines to/from STL and other containers and generic data structures.Regular Expressions: - Partial or full support to regular expressions.Other char types: - Character types like char_32 can be also supportedMini Text Editor: - This is a text editor based on CText that I plan to port on Modern C++.Export to Python: - I want to export CText library to Python-3Performance Test: - Add performance tests comparing with STL string.