Coder Social home page Coder Social logo

regexp_outkeys's Introduction

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.

regexp_outkeys's People

Contributors

thrynae avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.