substring replace in Find/Replace

Having trouble installing Oxygen? Got a bug to report? Post it all here.
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

substring replace in Find/Replace

Post by shudson310 »

Hello,

I'm trying to fix a series of issues with some keyrefs:
<xref keyref="topicname#topicname"/>

I basically want to search across the keyrefs in a project or directory and remove the # and substring after.

The result should be:
<xref keyref="topicname"/>

If I do a find in a file, I can use the regex #.*$, but I can't seem to restrict the search/replace to @keyref.

I've tried putting //@keyref in the Xpath field, and have the Regular Expressions checkbox selected, but I get 0 results.

What am I missing?

oXygen Editor v23.1 build 2021061407
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: substring replace in Find/Replace

Post by adrian »

Hello,

The XPath is fine. The problem is the $ from "#.*$". Oxygen always treats ^ and $ as line start and line end. Note that even if ^ and $ would refer to region start and region end, it still wouldn't work for the given case since the XPath region also includes the ending quotes.

So, a quick fix for this is to exclude the single and double quotes, with the regular expression:

Code: Select all

#[^'"]*
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: substring replace in Find/Replace

Post by shudson310 »

Worked perfectly. Thanks!
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
Post Reply