Regular Express
Tim Frost
timfrost at xtra.co.nz
Sun Jul 1 06:35:06 UTC 2007
On Sun, 2007-07-01 at 00:54 +0300, OOzy Pal wrote:
> I want to match either div and hash if the are enclosed with { } even
> if there are other char in between. For example
>
> Assume I have the following code
>
> {def hash = div( 'common')}
> <div>
>
> I would like to match the first div but not the second. I tried this but no help
>
> ^{*\b(div|hash)\b*\}
Try
\{.*\b(div|hash)\b.*\}
The '.*' says 'match any number of arbitrary characters', while your
original RE is saying 'match any number of "{" characters' and 'match
any number of word boundary characters'.
You may need to remove the '\' before the braces ( '{' and '}')
depending on which RE parser is being used.
Tim
More information about the ubuntu-users
mailing list