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
Post a Comment