Searching a String using regexp

3 ビュー (過去 30 日間)
Aryan Sinha
Aryan Sinha 2016 年 3 月 27 日
コメント済み: Walter Roberson 2016 年 3 月 28 日
ASDF=
Manager_Mark
NumOfAxes: 2
PoductVal: 142
VerifyBy : 'Mark'
John
FilesServed: 142
ClearedFile: 128
PendingFile: 14
Mark
FilesServed: 124
ClearedFile: 124
PendingFile: 0
ASDF is my charecter array with details. and all my details will be in this format.. The things which would be changing are "Manager_mark" , "John" and "Mark" .
I just need to find these three Strings within the data using regexp . I cannot use strfind as these three values gets randomly updated.. I tried using regexp but couldn't do so.. Can anyone tell me the effecient way (or) the expression needed to search the three values within this character array
  6 件のコメント
Walter Roberson
Walter Roberson 2016 年 3 月 28 日
And when you get an employee named "Danny:", what then?
Aryan Sinha
Aryan Sinha 2016 年 3 月 28 日
I need to group the properties..I mean ,. Danny and his associated properties

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2016 年 3 月 28 日
And how are you going to distinguish between an employee named "Danny:" (including the colon) and a property value prefixed by "Danny:" ?
I would put it to you that employee names and manager_ entries are prefixed with a certain number of blanks, and that properties for each employee or manager_ entry are prefixed with a different and larger number of blanks.
Assuming your char array has embedded newline to divide it into lines:
ASDF = strjoin( {
' Manager_Reza'
' NumOfAxes: 2'
' PoductVal: 142'
' VerifyBy : ''Reza'''
' VerifyOn : ''Dec-21'''
' Danny'
' FilesServed: 10'
' ClearedFile: 10'
' PendingFile: 0'
' Timothy'
' FilesServed: 129'
' ClearedFile: 12'
' PendingFile: 0'}.', char(10));
regexp(ASDF, '(?<=^\s{3})(\S+)', 'match', 'lineanchors')
If instead your char array is a 13 x something char array, blank padded, then to use regexp() on it you would need to cellstr() it, as regexp cannot be used on a 2D char array.
  3 件のコメント
Aryan Sinha
Aryan Sinha 2016 年 3 月 28 日
Hello Mr.Walter Roberson If the field has a white space then would it work ?
=Example : " Manager Reza " instead of Manager_Reza ??
I am trying to figure out the expression which you wrote and tweak it to make it work if the field has spaces...
Walter Roberson
Walter Roberson 2016 年 3 月 28 日
regexp(ASDF, '(?<=^\s{3})(.+)', 'match', 'lineanchors', 'dotexceptnewline')

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by