Needed to match characters on one line from start string >; to end string <
>;(.*?)<
Note:
.* –This will match all characters (except end of line), this is called greedy as it will keep on matching until eol. then backtrack as it still wants to match the <. It will therefore match from first to last.
.*? – This will make it not greedy and will match from >; to first instance of <
i.e.
Example
string to be searched:- >;banana<blinky>;apple<cider>;orange<beer>
Greedy
reg expressions:- >;(.*)<
result:- >;banana<blinky>;apple<cider>;orange<
Non Greedy
reg expressions:- >;(.*?)<
result:- >;banana<

No comments:
Post a Comment