0

i am getting a stack trace from a REST service which looks like:

 oracle.mds.core.MetadataNotFoundException: MDS-00013: no metadata found for metadata object "/WEB-INF/root_menu_tm.xml" [[MDS-00201: PDocument not found in MetadataStore : [store-type=DefaultMetadataStore app-name=ORA_CRM_UIAPP lookup-order=ServletContext,Classpath]     at oracle.mds.core.MetadataObject.getBaseMO(MetadataObject.java:1600)   at oracle.mds.core.MDSSession.getMetadataObject(MDSSession.java:1663)   at oracle.apps.fnd.applcore.patterns.uishell.model.ApplicationsMenuModel.getMetadatObject(ApplicationsMenuModel.java:891)   at oracle.apps.fnd.applcore.patterns.uishell.model.ApplicationsMenuModel._createModel(ApplicationsMenuModel.java:492)   at oracle.apps.fnd.applcore.patterns.uishell.model.ApplicationsMenuModel.setSource(ApplicationsMenuModel.java:177)  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at 

I am trying to format it in my javascript before displaying on UI. The idea is simple: just replace all the

<space>at

with

<br/>at

I have tried various options like:

var trace = (d.MsgDetails).replace(new RegExp('\sat','g'),'</p><p>at');

or

var trace = (d.MsgDetails).replace(new RegExp(' at','g'),'</p><p>at');

or

 var trace = (d.MsgDetails).replace(/at/g),'</p><p>at');

or

 var trace = (d.MsgDetails).replace(/ at/g),'</p><p>at');

and nothing works. I am hoping the space which it looks is really a space. removing the space works fine but that is not what i want as it will break good words too.

0

1 Answer 1

1

The character before “at” is a tab, so:

var trace = d.MsgDetails.replace(/\tat/g, '</p><p>at');

(Your first regular expression with \s would have worked if you had escaped \ in the string literal for an overall \\s; a string literal '\s' is equivalent to 's'. Don’t use the RegExp constructor to create static regular expressions.)

If there are in fact some newlines in there, a neater solution might be:

var traceLines = d.MsgDetails.split('\n');
var trace = document.createDocumentFragment();

traceLines.forEach(function (line) {
    trace.appendChild(document.createElement('p')).textContent = line;
});
Sign up to request clarification or add additional context in comments.

2 Comments

Doesn't \s match tabs? The OP's first attempt had /\sat/.
@nnnnnn: Explanation added

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.