5.0

5.0 | 2 ratings Rate this file 15 downloads (last 30 days) File Size: 3.58 KB File ID: #1518

strpat: a pedestrian, exactly matching pattern finder / replacer

by us

 

20 Mar 2002 (Updated 05 Jul 2006)

Code covered by the BSD License  

finds and/or replaces an exactly matching pattern in a string or a numeric array

Download Now | Watch this File

File Information
Description

STRPAT finds and/or replaces an EXACTLY matching pattern in a string or numeric array.

EXAMPLES
- strings
strpat('aa_a_aaa_aa','aa','X')
     X_a_aaa_X
strpat('aa_a_aaa_aa','a','XXX')
     aa_XXX_aaa_aa

- as opposed to
strrep('aa_a_aaa_aa','a','XXX')
     XXXXXX_XXX_XXXXXXXXX_XXXXXX

- double array
strpat([[1:3] pi [5:7]],pi,nan)
     1 2 3 NaN 5 6 7
strpat(pi*[1:6],[4*pi 5*pi],[])
     3.1416 6.2832 9.4248 18.85
strpat(pi*[1:6],[4*pi 5*pi],[nan inf -inf nan])
     3.1416 6.2832 9.4248 NaN Inf -Inf NaN 18.85
strpat(pi*[1:6],[4*pi 5*pi],[1:3])
     3.1416 6.2832 9.4248 1 2 3 18.85

MATLAB release MATLAB 6.1 (R12.1)
Zip File Content  
Other Files strpat13.m,
strpat.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
06 Sep 2007 Leandro Navarro  
19 Apr 2008 Carlos Adrian Vargas Aguilera

I downloaded it because I found it at 2nd place at "Most downloaded"!, and I found it very useful. I just would prefer a WARNING message instead of a DISPLAY, in order to be able to avoid it and just looking into the .n field at the second output, which, by the way, was very clever.

Thanks us for the submission.

Please login to add a comment or rating.
Updates
18 Feb 2003

simply changed submission name!

18 Feb 2003

adjusted use of LOGICAL to new def in R13

19 May 2003

enhanced help

21 May 2003

enhanced help

03 Jan 2006

returns an error message if it does not find an exactly matching pattern; version tag 30-Dec-2005 18:44:23

05 Jul 2006

changed engine for r14/r2006 versions, which runs much faster (no EVAL!). the old version has been added as STRPAT13. version tag 05-Jul-2006 16:12:19

Tag Activity for this File
Tag Applied By Date/Time
strings us 22 Oct 2008 06:43:08
string us 22 Oct 2008 06:43:08
numeric us 22 Oct 2008 06:43:08
array us 22 Oct 2008 06:43:08
pattern us 22 Oct 2008 06:43:08
match us 22 Oct 2008 06:43:08
find us 22 Oct 2008 06:43:08
strrep us 22 Oct 2008 06:43:08
exact us 22 Oct 2008 06:43:08
replace us 22 Oct 2008 06:43:08
match Kainjan Kotecha 20 Mar 2009 05:28:37
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com