regex - Matching regular expression only at beginning of line in MATLAB -


i have string spans multiple lines. line breaks lf, in example of "hello world" has line break between "hello" , "world":

some_bytes = [104  101  108  108  111 10 119  111  114  108  100]; some_string = char(some_bytes);  disp(some_string) 

i want match sequence "wo", if occurs @ beginning of line. using regular expression

idx = regexpi(some_string,'^wo'); 

returns empty array. doing wrong?

^, default, matches @ beginning of string. can activate multiline mode using (?m) search flag:

idx = regexpi(some_string,'(?m)^wo'); 

alternatively, can supply option 'lineanchors'. see documentation.


Comments

Popular posts from this blog

Using 'OR' and 'AND' in SQL Server -

python - Finding intersection between ellipse and a line -

c++ - NetBeans Remote Development with additional configuration -