Skip to main content

Pure Javascript

Pure Javascript


Regex

remove line breaks:

following seems to do the trick:


var wn_formatted =  work_notes.replace(/\r?\n|\r/g, ';'); //replaces carriage return with ;

Comments

  1. Replies
    1. thank you for your feedback

      Delete
    2. This is a concise and practical JavaScript example showing how regular expressions can be used to remove line breaks from text. The focus on a simple problem and a compact solution makes the example useful for developers who are learning how JavaScript handles text manipulation.

      The regex approach is particularly helpful because similar text-cleaning tasks often appear when processing user input, formatted strings, or content received from external sources. For learners who want to strengthen their understanding of JavaScript syntax and practical programming techniques, a JavaScript Online Course can provide a structured foundation.

      Delete
  2. Replies
    1. I also like that the example demonstrates how a small regular-expression pattern can solve a repetitive text-processing task without requiring a lengthy implementation. Developers who want more hands-on practice with JavaScript features and everyday coding techniques can benefit from JavaScript Online Training.

      Delete
  3. It's an excellent article you've written here about Commercial Cleaning Software Your article provided me with some unique and useful knowledge. Thank you for bringing this post to our attention.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. That’s a helpful read! I’ve been part of online education for a while now, and I can vouch for the impact of focused, 1:1 attention—particularly for students tackling studies in their Online Tuition for Class 8.

    ReplyDelete
  6. Helpful perspective shared here. Preparing for A Levels can sometimes feel overwhelming without proper guidance. Many students benefit from Online A Level Tuition, as structured A Level Tuition sessions make revision and concept building much easier.

    ReplyDelete

Post a Comment

Popular posts from this blog

Get URL Parameter - server side script (portal or classic UI)

Classic UI : var sURL_editparam = gs . action . getGlideURI (). getMap (). get ( ' sysparm_aparameter ' ); if ( sURL_editparam == 'true' ) { gs . addInfoMessage ( 'parameter passed ); } Portal : var sURL_editparam = $sp . getParameter ( " sysparm_aparameter " ); if ( sURL_editparam == 'true' ) { gs . addInfoMessage ( 'parameter passed ); }

ServiceNow timeout settings for virtual agent chat

  After connecting to live agent User is connected to live agent and not responding to live agent chat or distracted. The below properties controls the timeout settings, the OOB settings for reminder is [180 sec] and for cancelling the chat is [360 sec]. The job is default configured to 2 min so I believe no tweaking is required here.  Property -   com.glide.cs.idle_chat_reminder_timeout                  com.glide.cs.idle_chat_cancel_timeout Scheduled job   - Idle Chat Timer Task   https://community.servicenow.com/community?id=community_article&sys_id=1453b03bdbaad0109e691ea668961929   (ServiceNow ) 

ServiceNow check for null or nil or empty (or not)

Haven't tested these all recently within global/local scopes, so feel free to have a play! option 1 use an encoded query embedded in the GlideRecord , e.g.  var grProf = new GlideRecord ( 'x_cls_clear_skye_i_profile' ); grProf . addQuery ( 'status=1^ owner=NULL ' ); grProf . query (); even better use the glideRecord  addNotNullQuery or addNullQuery option 2 JSUtil.nil / notNil (this might be the most powerful. See this link ) example: if ( current . operation () == 'insert' && JSUtil . notNil ( current . parent ) && ! current . work_effort . nil ())  option 3 there might be times when you need to get inside the GlideRecord and perform the check there, for example if the code goes down 2 optional routes depending on null / not null can use gs.nil : var grAppr = new GlideRecord ( 'sysapproval_approver' ); var grUser = new GlideRecord ( 'sys_user' ); if ( grUser . get ( 'sys_id' , current . approver )){...