regexp_outkeys

Version 2.0.0.1 (11,9 ko) par Rik
Extend the regexp function for old Matlab releases
4 téléchargements
Mise à jour 12 sept. 2023

regexp_outkeys documentation

View regexp_outkeys on File Exchange Open in MATLAB Online

Table of contents

Description

This function extends the regexp function for old Matlab releases.
On older versions of Matlab the regexp function did not allow you to specify the output keys. This function has an implementation of the split, match, and tokens output keys, so they can be used on any version of Matlab or GNU Octave.

Note that the builtin regexp function is still used, so any limitation and bugs still apply. As an example; the lookaround assertions ((?<=test)expr etc) were introduced in v7 (R14) and are therefore not supported in this function either on v6.5.

Matlab/Octave

Syntax

out = regexp_outkeys(str,expression,outkey);
[out1,...,outN] = regexp_outkeys(str,expression,outkey1,...,outkeyN);
[___,startIndex] = regexp_outkeys(___);
[___,startIndex,endIndex] = regexp_outkeys(___);

Output arguments

Argument Description
out The result specified by the outkey:
'start': numeric array with the starting indices of the matches.
'end': numeric array with the ending indices of the matches.
'match': cellstr with the matches.
'split': cellstr with the non-matches.
'tokens': nested cellstr with the matched tokens.
startIndex Same result as 'start' outkey.
endIndex Same result as 'end' outkey.

Input arguments

Argument Description
str A char array containing the text to be searched.
expression Regular expression. See the documentation for regexp for more explanation.
outkey One of the supported outkeys: 'match', 'split', 'tokens', 'start', and 'end'. Duplicates are allowed.

Examples

A few examples of valid syntax options:

str = 'lorem1 ipsum1.2 dolor3 sit amet 99 ';
words = regexp_outkeys(str,' ','split')
numbers = regexp_outkeys(str,'[0-9.]*','match')
RawTokens = regexp_outkeys(str,'([a-z]+)[0-9]','tokens');
words_with_number = horzcat(RawTokens{:})
[white,end1,start,end2] = regexp_outkeys(str,' ','match','end')

Compatibility, version info, and licence

Compatibility considerations:

  • Only the 'match', 'split', 'tokens', 'start', and 'end' options are supported. The additional options provided by regexp are also not implemented.
  • Cell array input is not supported.
Test suite result Windows Linux MacOS
Matlab R2022b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2022a W11 : Pass
Matlab R2021b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2021a W11 : Pass
Matlab R2020b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2020a W11 : Pass
Matlab R2019b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2019a W11 : Pass
Matlab R2018a W11 : Pass ubuntu_22.04 : Pass
Matlab R2017b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2016b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2015a W11 : Pass ubuntu_22.04 : Pass
Matlab R2013b W11 : Pass
Matlab R2007b W11 : Pass
Matlab 6.5 (R13) W11 : Pass
Octave 8.2.0 W11 : Pass
Octave 7.2.0 W11 : Pass
Octave 6.2.0 W11 : Pass ubuntu_22.04 : Pass Catalina : Pass
Octave 5.2.0 W11 : Pass
Octave 4.4.1 W11 : Pass Catalina : Pass
Version: 2.0.0.1
Date:    2023-09-12
Author:  H.J. Wisselink
Licence: CC by-nc-sa 4.0 ( https://creativecommons.org/licenses/by-nc-sa/4.0 )
Email = 'h_j_wisselink*alumnus_utwente_nl';
Real_email = regexprep(Email,{'*','_'},{'@','.'})

Test suite

The tester is included so you can test if your own modifications would introduce any bugs. These tests form the basis for the compatibility table above. Note that functions may be different between the tester version and the normal function. Make sure to apply any modifications to both.

Citation pour cette source

Rik (2024). regexp_outkeys (https://github.com/thrynae/regexp_outkeys/releases/tag/v2.0.0.1), GitHub. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2021b
Compatible avec les versions R13SP1 et ultérieures
Plateformes compatibles
Windows macOS Linux
Tags Ajouter des tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
2.0.0.1

See release notes for this release on GitHub: https://github.com/thrynae/regexp_outkeys/releases/tag/v2.0.0.1

2.0.0

See release notes for this release on GitHub: https://github.com/thrynae/regexp_outkeys/releases/tag/v2.0.0

1.1.0

See release notes for this release on GitHub: https://github.com/thrynae/regexp_outkeys/releases/tag/v1.1.0

1.0.1

See release notes for this release on GitHub: https://github.com/thrynae/regexp_outkeys/releases/tag/1.0.1

1.0.0

Pour consulter ou signaler des problèmes liés à ce module complémentaire GitHub, accédez au dépôt GitHub.
Pour consulter ou signaler des problèmes liés à ce module complémentaire GitHub, accédez au dépôt GitHub.