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

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -