strings-1.2.0/COPYING0000644000000000000000000000004212534664335012373 0ustar 00000000000000See individual files for licenses strings-1.2.0/DESCRIPTION0000644000000000000000000000056512534664335013060 0ustar 00000000000000Name: strings Version: 1.2.0 Date: 2015-06-06 Author: various authors Maintainer: Oliver Heimlich Title: String Handling. Description: Additional functions for manipulation and analysis of strings. Depends: octave (>= 3.8.0) Autoload: no BuildRequires: pcre-devel [Debian] libpcre3-dev License: GPLv3+, FreeBSD Url: http://octave.sourceforge.net/strings/ strings-1.2.0/INDEX0000644000000000000000000000017112534664335012135 0ustar 00000000000000strings >> Strings Search and replace pcregexp Operations editdistance cstrcmp Conversion base64encode base64decode strings-1.2.0/NEWS0000644000000000000000000000152312534664335012044 0ustar 00000000000000Summary of important user-visible changes for strings 1.2.0: ------------------------------------------------------------------- ** The following functions have been removed since they are part of Octave core since 3.8: strjoin, strsort (use sort) ** The function editdistance has been almost rewritten and will perform much faster. ** Compatibility with Octave 4.0.0. Summary of important user-visible changes for strings 1.1.0: ------------------------------------------------------------------- ** The following functions have been removed since they are part of Octave core since 3.6.0: strtrim ** Package is no longer automatically loaded. ** The function `cstrcmp' has been completely rewritten. It should perform faster and will accept arguments exactly the same way as Octave's core `strcmp'. strings-1.2.0/inst/base64decode.m0000644000000000000000000000751512534664335014737 0ustar 00000000000000## Copyright (C) 2007 Muthiah Annamalai ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{rval} =} base64decode (@var{code}) ## @deftypefnx {Function File} {@var{rval} =} base64decode (@var{code}, @var{as_string}) ## Convert a base64 @var{code} (a string of printable characters according to RFC 2045) ## into the original ASCII data set of range 0-255. If option @var{as_string} is ## passed, the return value is converted into a string. ## ## @example ## @group ## base64decode ('SGFrdW5hIE1hdGF0YQ==', true) ## @result{} Hakuna Matata ## @end group ## @end example ## ## See: http://www.ietf.org/rfc/rfc2045.txt ## ## @seealso {base64encode} ## @end deftypefn function z = base64decode (X, as_string) if (nargin < 1 ) print_usage; elseif nargin == 1 as_string=false; endif if ( any(X(:) < 0) || any(X(:) > 255)) error("base64decode is expecting integers in the range 0 .. 255"); endif ## decompose strings into the 4xN matrices ## formatting issues. if( rows(X) == 1 ) Y=[]; L=length(X); for z=4:4:L Y=[Y X(z-3:z)']; #keep adding columns end if min(size(Y))==1 Y=reshape(Y,[L, 1]); else Y=reshape(Y,[4,L/4]); end X=Y; Y=[]; end X = toascii(X); Xa= X; ## Work backwards. Starting at step in table, ## lookup the index of the element in the table. ## 6-bit encoding table, plus 1 for padding ## 26*2 + 10 + 2 + 1 = 64 + 1, '=' is EOF stop mark. table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; S=size(X); SRows=S(1); SCols=S(2); Y=zeros(S); ## decode the incoming matrix & ## write the values into Va matrix. Va = -1*ones(size(Xa)); iAZ = (Xa >= 'A').*(Xa <= 'Z') > 0; Va(iAZ)=Xa(iAZ)-'A'; iaz = (Xa >= 'a').*(Xa <= 'z') > 0; Va(iaz)=Xa(iaz)-'a'+26; i09 = (Xa >= '0').*(Xa <= '9') > 0; Va(i09)=Xa(i09)-'0'+52; is = (Xa == '/') ; Va(is) = 63; ip = (Xa == '+') ; Va(ip) = 62; ieq = (Xa == '=') ; Va(ieq) = 0; clear is; clear ieq; clear ip; clear i09; clear iaz; clear iAZ; clear Xa; clear X; Y=Va; clear Va; Y1=Y(1,:); if (SRows > 1) Y2=Y(2,:); else Y2=zeros(1,SCols); end; if (SRows > 2) Y3=Y(3,:); else Y3=zeros(1,SCols); end; if (SRows > 3) Y4=Y(4,:); else Y4=zeros(1,SCols); end; ## +1 not required due to ASCII subtraction ## actual decoding work b1 = Y1*4 + fix(Y2/16); b2 = mod(Y2,16)*16+fix(Y3/4); b3 = mod(Y3,4)*64 + Y4; ZEROS=sum(sum(Y==0)); L=length(b1)*3; z=zeros(1,L); z(1:3:end)=b1; if (SRows > 1) z(2:3:end)=b2; else z(2:3:end)=[]; end; if (SRows > 2) z(3:3:end)=b3; else z(3:3:end)=[]; end ## FIXME ## is this expected behaviour? if ( as_string ) L=length(z); while ( ( L > 0) && ( z(L)==0 ) ) L=L-1; end z=char(z(1:L)); end endfunction %!assert(base64decode(base64encode('Hakuna Matata'),true),'Hakuna Matata') %!assert(base64decode(base64encode([1:255])),[1:255]) %!assert(base64decode(base64encode('taken'),true),'taken') %!assert(base64decode(base64encode('sax'),true),'sax') %!assert(base64decode(base64encode('H'),true),'H') %!assert(base64decode(base64encode('Ta'),true),'Ta') strings-1.2.0/inst/base64encode.m0000644000000000000000000000437312534664335014750 0ustar 00000000000000## Copyright 2006(?) Paul Kienzle ## Copyright 2015 Oliver Heimlich ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{Y} =} base64encode (@var{X}) ## @deftypefnx {Function File} {@var{Y} =} base64encode (@var{X}, @var{row_vector}) ## Convert @var{X} into string of printable characters according to RFC 2045. ## ## The input may be a string or a matrix of integers in the range 0..255. ## ## If want the output in the 1-row of strings format, pass the ## @var{row_vector} argument as @code{true}. Otherwise the output is a 4-row ## character matrix, which contains 4 encoded bytes in each column for each ## 3 bytes from the input. ## ## Example: ## @example ## @group ## base64encode ('Hakuna Matata', true) ## @result{} SGFrdW5hIE1hdGF0YQ== ## @end group ## @end example ## @seealso{base64decode, base64_encode} ## @end deftypefn function Y = base64encode (X, row_vector) if (nargin < 1 || nargin > 2) print_usage; endif if (nargin < 2) row_vector = false; endif if (ischar (X)) X = toascii (X); endif if (any (X != fix (X)) || any (X < 0 | X > 255)) error ("base64encode is expecting integers in the range 0 .. 255"); endif Y = base64_encode (uint8 (X)); if (not (row_vector)) Y = reshape (Y, 4, []); end endfunction %!assert (base64encode ('Hakuna Matata', true), 'SGFrdW5hIE1hdGF0YQ==') %!assert (base64encode ('Hakuna Matata', false), ['SdIdY'; ... %! 'GWEGQ'; ... %! 'F51F='; ... %! 'rhh0=']) strings-1.2.0/inst/cstrcmp.m0000644000000000000000000000757012534664335014163 0ustar 00000000000000## Copyright (C) 2007 Muthiah Annamalai ## Copyright (C) 2012 Carnë Draug ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{rval} =} cstrcmp (@var{s1}, @var{s2}) ## Compare strings @var{s1} and @var{s2} like the C function. ## ## Aside the difference to the return values, this function API is exactly the ## same as Octave's @code{strcmp} and will accept cell arrays as well. ## ## @var{rval} indicates the relationship between the strings: ## @itemize @bullet ## @item ## A value of 0 indicates that both strings are equal; ## @item ## A value of +1 indicates that the first character that does not match has a ## greater value in @var{s1} than in @var{s2}. ## @item ## A value of -1 indicates that the first character that does not match has a ## match has a smaller value in @var{s1} than in @var{s2}. ## @end itemize ## ## @example ## @group ## cstrcmp ("marry", "marry") ## @result{} 0 ## cstrcmp ("marry", "marri") ## @result{} 1 ## cstrcmp ("marri", "marry") ## @result{} -1 ## @end group ## @end example ## ## @seealso {strcmp, strcmpi} ## @end deftypefn function rval = cstrcmp (s1, s2) if (nargin != 2) print_usage(); endif ## this function is just like Octave's strcmp but the 0 and 1 need to be ## inverted. Once is done, if there are 1, we need to decide if they will ## be positive or negative. Also, since it's possible that the value needs ## to be negative, class must be double (strcmp returns logical) rval = double(!strcmp (s1, s2)); if (!any (rval)) ## all zeros, no need to do anything else return endif ## get index of the ones we have to "fix" idx = find (rval == 1); ## if any is not a cell, this simplifies the code that follows if (!iscell (s1)), s1 = {s1}; endif if (!iscell (s2)), s2 = {s2}; endif ## there's 2 hypothesis: ## - arrays have same length (even if it's only one cell) ## - arrays have different lengths (in which case, one will have a single cell) if (numel (s1) == numel (s2)) rval(idx) = cellfun (@get_sign, s1(idx), s2(idx)); elseif (numel (s1) > 1) rval(idx) = cellfun (@get_sign, s1(idx), s2(1)); elseif (numel (s2) > 1) rval(idx) = cellfun (@get_sign, s1(1), s2(idx)); endif endfunction function r = get_sign (s1, s2) ## strings may have different lengths which kinda complicates things ## in case the strings are of different size, we need to make them equal ## If once "trimmed", the strings are equal, the "shortest" string is ## considered smaller since the comparison is made by filling it with null ns1 = numel (s1); ns2 = numel (s2); nmin = min (ns1, ns2); ## if one of the strings is empty, we are already done if (nmin == 0), r = sign (ns1 - ns2); return endif s = sign (s1(1:nmin) - s2(1:nmin)); if (any (s)) ## if there's any difference between this part of the two strings, get the ## index of the first occurence and return its value r = s(find (s != 0, 1)); else r = sign (ns1 - ns2); endif endfunction %!assert(cstrcmp("hello","hello"),0); %!assert(cstrcmp("marry","marie"),+1); %!assert(cstrcmp("Matlab","Octave"),-1); %!assert(cstrcmp("Matlab",{"Octave","Scilab","Lush"}), [-1 -1 +1]); %!assert(cstrcmp({"Octave","Scilab","Lush"},"Matlab"), [+1 +1 -1]); strings-1.2.0/inst/editdistance.m0000644000000000000000000001707212534664335015146 0ustar 00000000000000## Copyright (C) 2006 Muthiah Annamalai ## Copyright (C) 2014 Max Görner ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{dist}, @var{L}] =} editdistance (@var{str1}, @var{str2}) ## @deftypefnx {Function File} {[@var{dist}, @var{L}] =} editdistance (@var{str1}, @var{str2}, @var{weights}) ## @deftypefnx {Function File} {[@var{dist}, @var{L}] =} editdistance (@var{str1}, @var{str2}, @var{weights}, @var{modus}) ## Compute the Levenshtein edit distance between the two strings. ## ## The optional argument @var{weights} specifies weights for the deletion, ## matched, and insertion operations; by default it is set to +1, 0, +1 ## respectively, so that a least editdistance means a closer match between the ## two strings. This function implements the Levenshtein edit distance as ## presented in Wikipedia article, accessed Nov 2006. Also the levenshtein edit ## distance of a string with the empty string is defined to be its length. ## ## For the special case that there are no weights given and the array L is not ## requested, an algorithm of Berghel and Roach, which improves an algorithm ## introduced by Ukkonen in 1985, will be applied. This algorithm is ## significantly faster most of the times. Its main strength lies in cases with ## small edit distances, where huge speedups and memory savings are suspectible. ## The time (and space) complexity is O(((dist^2 - (n - m)^2)/2) + dist), where ## n and m denote the length of both strings. ## ## The optional argument @var{modus} specifies the algorithm to be used. For ## @var{modus} = 0, Berghel and Roach's algorithm will be used whenever ## possible. For @var{modus} = 1, the classic algorithm by Fisher and Wagner ## will be used. If @var{L} is omitted, and @var{modus} = 1, a variant of Fisher ## and Wagner's algorithm using only a linear amount of memory with respect to ## the input length, but O(m*n) runtime, will be used. Again, n and m denote the ## length of both strings. ## ## The default return value @var{dist} is the edit distance, and ## the other return value @var{L} is the distance matrix. ## ## @example ## @group ## editdistance ('marry', 'marie') ## @result{} 2 ## @end group ## @end example ## ## @end deftypefn function [dist, L] = editdistance (str1, str2, weights = [1 0 1], modus = 0) #Checking correct call of the function. if (nargin < 2 || nargin > 4) print_usage (); endif if (nargin >= 3 && numel (weights) != 3) error ("editdistance: WEIGTHS must be a 3 element vector.") endif if (!isvector(str1) || !isvector(str2)) error ("editdistance: Both strings must be a vector.") endif #Using the approach of Berghel and Roach, if possible. if (modus == 0 && nargout < 2 && (weights(1) == weights(3) && weights(2) == 0) ) dist = weights(1)*editdistance_berghel_roach (str1,str2); return; endif saveMemory = nargout < 2; L1 = numel (str1) + 1; L2 = numel (str2) + 1; #Checking whether str1 or str2 are empty strings. If so, the determination of the minimal edit distance is trivial. if (L1 == 1) dist = L2-1; return; elseif (L2 == 1) dist = L1-1; return; endif if (saveMemory) L = zeros (2,L2); else L = zeros (L1,L2); endif %Setting weights g = weights(1); %insertion m = weights(2); %match d = weights(3); %deletion if (not (saveMemory)) L(:,1) = [0:L1-1]'*g; endif L(1,:) = [0:L2-1]*g; for idx = 2:L1; if (saveMemory) L(2, 1) = idx-1; endif for idy = 2:L2 if (str1(idx-1) == str2(idy-1)) score = m; else score = d; endif if (saveMemory) x = 2; else x = idx; endif m1 = L(x-1,idy-1) + score; m2 = L(x-1,idy) + g; m3 = L(x,idy-1) + g; L(x,idy) = min ([m1, m2, m3]); endfor if (saveMemory) L(1, :) = L(2, :); endif endfor if (saveMemory) x = 2; else x = L1; endif dist = L(x,L2); endfunction function dist = editdistance_berghel_roach (a,b) #Variables named according to Berghel and Roach 1996 (except s, which is called dist here) if (!isvector(a) || !isvector(b)) print_usage(); endif if (numel (a) > numel (b)) ans = a; a = b; b = ans; endif m = numel (a); n = numel (b); if (m == 0) dist = n; return; endif MIN_K = -m-1; #The diagonal with the lowest number is -m MIN_P = -1; #minimum p that has to be cached is 0 FKP = sparse (m+n+2,n+1); FKP_cached = sparse (m+n+2,n+1); p = n-m; do inc = p; for temp_p = 0:p-1 if (abs (n-m - inc) <= temp_p) get_f ((n-m) - inc, temp_p); endif if (abs(n-m + inc) <= temp_p) get_f(n-m+inc,temp_p); endif inc--; endfor get_f (n-m,p); p++; until (get_f (n-m,p-1) == m); dist = p-1; function f = get_f (k,p) if (p == abs (k)-1) if (k < 0) f = abs (k) - 1; else f = -1; endif return; endif if (p < abs (k)-1) f = -inf; return; endif if (FKP_cached(k-MIN_K,p-MIN_P) == 1) f = FKP(k-MIN_K,p-MIN_P); return; endif c1 = get_f (k,p-1) + 1; c2 = get_f (k-1,p-1); c3 = get_f (k+1,p-1) + 1; t = max ([c1 c2 c3]); #if (a([t, t+1]) == b([k+t+1, k+t]) t2 = t+1; endif #taking adjacent transpositions into account while (t < m && t+k < n && a(t+1) == b(t+1+k)) t += 1; endwhile if (t > m || t+k > n) f = FKP(k-MIN_K,p-MIN_P) = NaN; else f = FKP(k-MIN_K,p-MIN_P) = t; endif FKP_cached(k-MIN_K,p-MIN_P) = 1; endfunction endfunction %!test %! l = 50; %! n = 20; %! rand('state',31513); %! abc = 'A':'Z'; %! %! for it = 1:n %! #Generate two Strings %! #This kind of generation produces worst case examples for the new algorithm, %! #so runtime comparisons won't be informative. %! str1 = str2 = abc(randi([1 length(abc)],1,l)); %! m = randi(l/2); %! str1(randi([1 l],1,m)) = abc(randi([1 length(abc)],1,m)); %! m = randi(l/2); %! str2(randi([1 l],1,m)) = abc(randi([1 length(abc)],1,m)); %! %! d1 = editdistance(str1,str2); #Berghel and Roach %! tempDist = editdistance(str2,str1); %! assert(d1 == tempDist, "editdistance: Berghel and Roach algorithm is not symmetric."); %! [d2 ~] = editdistance(str1,str2); #Fisher and Wagner %! [tempDist ~] = editdistance(str2,str1); %! assert(d2 == tempDist, "editdistance: Fisher and Wagner algorithm is not symmetric."); %! d3 = editdistance(str1,str2,[1 0 1],1); #Fisher and Wagner with linear memory usage %! tempDist = editdistance(str2,str1,[1 0 1],1); %! assert(d3 == tempDist, "editdistance: Fisher and Wagner algorithm with linear memory usage is not symmetric."); %! assert(d1 == d2, "editdistance: The result of the algorithm by Berghel and Roach and that of the algorithm by Fisher and Wagners differ."); %! assert(d2 == d3, "editdistance: The results of the algorithm by Fisher and Wagner with and without linear memory usage differ."); %! endfor strings-1.2.0/src/Makefile0000644000000000000000000000051012534664335013567 0ustar 00000000000000OCTAVE ?= octave MKOCTFILE ?= mkoctfile -Wall PCRE_SWITCHES := $(shell $(OCTAVE) \ --no-gui --no-init-file --no-site-file --silent --no-history \ --eval 'disp (octave_config_info ("PCRE_LIBS"));' \ --eval 'disp (octave_config_info ("PCRE_CPPFLAGS"));' \ ) pcregexp.oct: %.oct: %.cc $(MKOCTFILE) $(PCRE_SWITCHES) -o $@ $< strings-1.2.0/src/pcregexp.cc0000644000000000000000000001050512534664335014260 0ustar 00000000000000// Copyright (C) 2004 Stefan van der Walt // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1 Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2 Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS'' // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include #include //FIXME This function needs some documentation DEFUN_DLD(pcregexp, args, nargout, "\ -*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@dots{}] =} pcregexp (@dots{})\n\ Perl-compatible regular expression matching.\n\ \n\ Check your system's @code{pcre} man page.\n\ \n\ @seealso{regexp}\n\ @end deftypefn\n\ ") { octave_value_list retval = octave_value_list(); if (args.length() != 2) { print_usage (); return retval; } std::string pattern = args(0).string_value(); std::string input = args(1).string_value(); if (error_state) { gripe_wrong_type_arg("pcregexp", args(0)); return retval; } // Compile expression pcre *re; const char *err; int erroffset; re = pcre_compile(pattern.c_str(), 0, &err, &erroffset, NULL); if (re == NULL) { error("pcregexp: %s at position %d of expression", err, erroffset); return retval; } // Get nr of subpatterns int subpatterns; int status = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &subpatterns); // Match expression OCTAVE_LOCAL_BUFFER(int, ovector, (subpatterns+1)*3); int matches = pcre_exec(re, NULL, input.c_str(), input.length(), 0, 0, ovector, (subpatterns+1)*3); if (matches == PCRE_ERROR_NOMATCH) { for (int i=nargout-1; i>=0; i--) retval(i) = ""; retval(0) = Matrix(); pcre_free(re); return retval; } else if (matches < -1) { error("pcregexp: internal error calling pcre_exec"); return retval; } const char **listptr; status = pcre_get_substring_list(input.c_str(), ovector, matches, &listptr); if (status == PCRE_ERROR_NOMEMORY) { error("pcregexp: cannot allocate memory in pcre_get_substring_list"); pcre_free(re); return retval; } // Pack indeces Matrix indeces = Matrix(matches, 2); for (int i = 0; i < matches; i++) { indeces(i, 0) = ovector[2*i]+1; indeces(i, 1) = ovector[2*i+1]; if (indeces(i, 0) == 0) indeces(i, 1) = 0; } retval(0) = indeces; // Pack substrings retval.resize(nargout + 1); for (int i = 0; i < matches; i++) { retval(i+1) = *(listptr+i+1); } // Free memory pcre_free_substring_list(listptr); pcre_free(re); if (nargout > matches) { error("pcregexp: too many return values requested"); return octave_value_list(); } return retval; } /* %!assert(pcregexp("f(.*)uck"," firetruck "),[2,10;3,7]); %!test %! [m,b]=pcregexp("f(.*)uck"," firetruck "); %! assert(m,[2,10;3,7]); %! assert(b, "iretr") %!test %! [m,b] = pcregexp("a(.*?)d", "asd asd"); %! assert(m, [1,3;2,2]); %! assert(b, "s"); %!test %! [m,b] = pcregexp("a", "A"); %! assert(isempty(m)) %! assert(b, "") %!fail("[m,b] = pcregexp('a', 'a')", "pcregexp") %!fail("pcregexp('(', '')", "pcregexp") %! %!demo %! [m, s1] = pcregexp("(a.*?(d))", "asd asd") */ strings-1.2.0/inst/test/pcregexp.cc-tst0000644000175000017500000000102612534664346017471 0ustar oliveroliver## DO NOT EDIT! Generated automatically from src/pcregexp.cc %!assert(pcregexp("f(.*)uck"," firetruck "),[2,10;3,7]); %!test %! [m,b]=pcregexp("f(.*)uck"," firetruck "); %! assert(m,[2,10;3,7]); %! assert(b, "iretr") %!test %! [m,b] = pcregexp("a(.*?)d", "asd asd"); %! assert(m, [1,3;2,2]); %! assert(b, "s"); %!test %! [m,b] = pcregexp("a", "A"); %! assert(isempty(m)) %! assert(b, "") %!fail("[m,b] = pcregexp('a', 'a')", "pcregexp") %!fail("pcregexp('(', '')", "pcregexp") %! %!demo %! [m, s1] = pcregexp("(a.*?(d))", "asd asd")