Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:11:00+00:00 2026-06-17T23:11:00+00:00

I noticed that trim() does not remove new line characters from the start and

  • 0

I noticed that trim() does not remove new line characters from the start and end of a string, so I am trying to accomplish this with the following regex:

return str.replace(/^\s\n+|\s\n+$/g,'');

This does not remove the new lines, and I fear I am out of my depth here.

EDIT
The string is being generated with ejs like so

go = ejs.render(data, { 
    locals: { 
        format() {
            // 
        }
    } 
});

And this is what go is, but with a few empty lines before. When I use go.trim() I still get the new lines before.

<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="Out" page-width="8.5in" page-height="11in" margin-top="1in" margin-bottom="0.5in" margin-left="0.75in" margin-right="0.75in">
            <fo:region-body margin-top="1in" margin-bottom="0.25in"/>
            <fo:region-before extent="1in"/>
            <fo:region-after extent="0.25in"/>
            <fo:region-start extent="0in"/>
            <fo:region-end extent="0in"/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="Out" initial-page-number="1" force-page-count="no-force">
        <fo:static-content flow-name="xsl-region-before">
            <fo:block font-size="14pt" text-align="center">ONLINE APPLICATION FOR SUMMARY ADVICE</fo:block>
            <fo:block font-size="13pt" font-weight="bold" text-align="center">Re:
                SDF, SDF
            </fo:block>

        </fo:static-content>

        <fo:flow flow-name="xsl-region-body" font="10pt Helvetica">

            .. removed this content

        </fo:flow>
    </fo:page-sequence>
</fo:root>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:11:01+00:00Added an answer on June 17, 2026 at 11:11 pm

    Try this:

    str = str.replace(/^\s+|\s+$/g, '');
    

    jsFiddle here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I noticed that IE 9 does not support application cache. How can I use
I just noticed to my surprise that whitespace at the start or end of
I noticed that the first creation of an image from an uri takes pretty
I noticed that median of boxplot (constructed with restricted ylim-parameter) may differ from the
I noticed that static assertions in class templates are not triggered when instantiations are
I noticed that the jQuery parseJSON basically does a simple regex check: parseJSON: function(
I'm getting a return string from a merchant account that looks like: RecurringID=8675309&RefNo=41:39&Notes= so
I've noticed that Java String will reuse char array inside it to avoid creating
Java String trim is not removing a whitespace character for me. String rank =
Before I start just letting you know that I'm new to OOP programming so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.