Find/Replace: Regular expression and XML-aware mode

Having trouble installing Oxygen? Got a bug to report? Post it all here.
HomeGoods
Posts: 96
Joined: Wed Feb 09, 2005 8:57 am

Find/Replace: Regular expression and XML-aware mode

Post by HomeGoods »

Suppose I have this XML document opened in Text mode

Code: Select all

<e>
<e bar="foo bar" />
<e bar="bar baz" />
<e baz="baz qux" />
</e>
and want to find and highlight the value of @bar that starts with 'b'; namely "bar baz" of the 2nd @bar.
I opened the Find/Replace dialog and set these options:
  • Find: ^b.*
  • XPath: @bar
  • Enable [Regular expression]
  • Enable [Enable XML search options] and [Attribute values]
But nothing's found. Looks like '^' in the regular expression doesn't work.
What's the correct syntax to accomplish the task?
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Find/Replace: Regular expression and XML-aware mode

Post by adrian »

HI,

This doesn't work because Oxygen always treats "^" as the line start, not a region start.
You can work around this with zero-width negative lookbehind:
Find: (?<!.)b.*

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
HomeGoods
Posts: 96
Joined: Wed Feb 09, 2005 8:57 am

Re: Find/Replace: Regular expression and XML-aware mode

Post by HomeGoods »

Now I've got it. Thanks!
Post Reply