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 - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -