MATLAB: Regular Expression to extract bigram

MATLAB

string = 'ab bc cd ef gh ij kl'
what will be the regular expression to extract bigram from the given string
I am writing the code
regexp(string,'\w* \w*','match');
the o/p is coming as: 'ab bc' 'cd' 'ef' 'gh' 'ij' 'kl'
while the output i am expecting as:
  • 'ab bc'
  • 'bc cd'
  • 'cd ef'
  • 'ef gh'
  • 'gh ij'
  • 'ij kl'

Best Answer

EDIT
Do you want?
string = 'ab bc cd ef gh ij kl'
regexp(string,'\s+','split');