How to replace a string with a particular value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2016 03:02 AM
Hi All,
I need to replace "YYY" string in "observations" column of "test" table with "location" of an "Opened by" column in "incident" table.
Below is the code to fetch the values containing "YYY" string. Can any one let me know how can I replace the "YYY" value with the location of an opened by person in incident table.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var inc=new GlideAggregate('u_test')
inc.query();
</g:evaluate>
<j:while test="${inc.next()}">
<j:if test="${inc.u_observations.indexOf('YYY') != -1}">
${inc.u_observations}<br/>
</j:if>
</j:while>
</j:jelly>
Thanks in advance for your valuable inputs.....
Thanks,
Sowmya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2016 04:15 AM
Hi Sowmya,
Implement a solution like this:
var abc ="abcde";
if(abc.indexOf('cd') != -1){
var temp=abc.slice(0,abc.indexOf('cd'));
var tempTail=abc.slice((abc.indexOf('cd')+2),abc.length);
abc=temp+"FGH"+tempTail;
}
Hope this would help you.
Thanks,
Subhankar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 10:55 PM
Hi Subhankar,
Thanks a lot. Your above suggested snippet helped me.....
Thanks,
sowmya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2016 02:36 AM
Welcome Sowmya!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2016 06:23 AM
You can also use the String.replace() function.
For example:
var myString = 'YYY XXX';
var newString = myString.replace('YYY', 'My new value');