Page 1 of 1

substring replace in Find/Replace

Posted: Fri Aug 06, 2021 6:25 pm
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

Re: substring replace in Find/Replace

Posted: Mon Aug 09, 2021 3:41 pm
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

Re: substring replace in Find/Replace

Posted: Mon Aug 09, 2021 5:37 pm
by shudson310
Worked perfectly. Thanks!