my $string = 'text1 text2 -f -DFLAG1 -global -DFLAG2 -DFLAG1'; my $pattern = '-D'; print substr($string, index($string, $pattern)), "\n";
index() returns the position, in the $string, of the first occurent of $pattern. Then substr uses the position to return everything after it inside $string. This should be simpler and much faster than using a .* regex.
In reply to Re: Regular Expression
by dkubb
in thread Regular Expression
by ashok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |