Using regexp to match multiple substrings, two questions
Mostra commenti meno recenti
Hi all, Simple two part question.
1) I have a function where regexp needs to match two terms in a string.
st1='This string is going to be searched'
Expression should evaluate to True if st1 contains 'going' and 'search'.
I stole the following syntax from an old StackOverflow thread. I understand why it works. My question is, why is the '^' necessary? What is it doing?
hasMatch=~isempty(regexp(st1,'^(?=.*going).*(?=.*search).*'))
2) This code will be in a function. I would like to generalize it to any number of substrings that need to be matched. I understand varargin, but I'm not clever enough with regexp to code an arbitrary number of substrings that must be matched. Any help would be welcome.
Thanks!
-Aram
3 Commenti
Aram Schiffman
il 27 Nov 2017
Modificato: Aram Schiffman
il 27 Nov 2017
Stephen23
il 27 Nov 2017
@Aram Schiffman: a regular expression is fundamentally order-dependent. You should consider other solutions.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Texas Instruments C2000 Processors in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!