|
On Thu, 26 Feb 2009 12:25:06 -0500, spasmous <spasmous@gmail.com> wrote:
> A weird problem when there are parentheses inside the pattern to be
> searched.
>
> str = '(0018,0011) DS 128 # 1, 4 Columns'
>
> patt = '(0018,0011) DS ';
> regexp(str,patt)
> ans = []
>
> % take off leading parenthesis
> patt = '0018,0011) DS ';
> regexp(str,'0018,0011)\sDS')
> ans = 2
>
> The first search fails when the pattern has both '(' and ')' enclosing
> part of the string. Is this a bug?
'(' has specical significance when it appears with a ')' in the pattern,
hence needs to be escaped
>> regexp('((','(')
ans =
1 2
>> regexp('((','\(')
ans =
1 2
>> regexp('()()','()')
ans =
[]
>> regexp('()()','\(\)')
ans =
1 3
|